-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dacd470
commit b38d5a8
Showing
23 changed files
with
1,261 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,5 @@ doc/api/ | |
*.js_ | ||
*.js.deps | ||
*.js.map | ||
|
||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
enum RecorderAudioChannel { INPUT, OUTPUT } | ||
|
||
/// RTCDataChannelMessage type | ||
enum MessageType { text, binary } | ||
|
||
enum RTCDataChannelState { | ||
RTCDataChannelConnecting, | ||
RTCDataChannelOpen, | ||
RTCDataChannelClosing, | ||
RTCDataChannelClosed, | ||
} | ||
|
||
enum RTCSignalingState { | ||
RTCSignalingStateStable, | ||
RTCSignalingStateHaveLocalOffer, | ||
RTCSignalingStateHaveRemoteOffer, | ||
RTCSignalingStateHaveLocalPrAnswer, | ||
RTCSignalingStateHaveRemotePrAnswer, | ||
RTCSignalingStateClosed | ||
} | ||
|
||
enum RTCIceGatheringState { | ||
RTCIceGatheringStateNew, | ||
RTCIceGatheringStateGathering, | ||
RTCIceGatheringStateComplete | ||
} | ||
|
||
enum RTCPeerConnectionState { | ||
RTCPeerConnectionStateClosed, | ||
RTCPeerConnectionStateFailed, | ||
RTCPeerConnectionStateDisconnected, | ||
RTCPeerConnectionStateNew, | ||
RTCPeerConnectionStateConnecting, | ||
RTCPeerConnectionStateConnected | ||
} | ||
|
||
enum RTCIceConnectionState { | ||
RTCIceConnectionStateNew, | ||
RTCIceConnectionStateChecking, | ||
RTCIceConnectionStateCompleted, | ||
RTCIceConnectionStateConnected, | ||
RTCIceConnectionStateCount, | ||
RTCIceConnectionStateFailed, | ||
RTCIceConnectionStateDisconnected, | ||
RTCIceConnectionStateClosed, | ||
} | ||
|
||
enum RTCVideoViewObjectFit { | ||
RTCVideoViewObjectFitContain, | ||
RTCVideoViewObjectFitCover, | ||
} | ||
enum RTCRtpMediaType { | ||
RTCRtpMediaTypeAudio, | ||
RTCRtpMediaTypeVideo, | ||
RTCRtpMediaTypeData, | ||
} | ||
|
||
final typeRTCRtpMediaTypetoString = <RTCRtpMediaType, String>{ | ||
RTCRtpMediaType.RTCRtpMediaTypeAudio: 'audio', | ||
RTCRtpMediaType.RTCRtpMediaTypeVideo: 'video', | ||
RTCRtpMediaType.RTCRtpMediaTypeData: 'data', | ||
}; | ||
|
||
final typeStringToRTCRtpMediaType = <String, RTCRtpMediaType>{ | ||
'audio': RTCRtpMediaType.RTCRtpMediaTypeAudio, | ||
'video': RTCRtpMediaType.RTCRtpMediaTypeVideo, | ||
'data': RTCRtpMediaType.RTCRtpMediaTypeData, | ||
}; | ||
|
||
enum TransceiverDirection { | ||
SendRecv, | ||
SendOnly, | ||
RecvOnly, | ||
Inactive, | ||
} | ||
|
||
final typeStringToRtpTransceiverDirection = <String, TransceiverDirection>{ | ||
'sendrecv': TransceiverDirection.SendRecv, | ||
'sendonly': TransceiverDirection.SendOnly, | ||
'recvonly': TransceiverDirection.RecvOnly, | ||
'inactive': TransceiverDirection.Inactive, | ||
}; | ||
|
||
final typeRtpTransceiverDirectionToString = <TransceiverDirection, String>{ | ||
TransceiverDirection.SendRecv: 'sendrecv', | ||
TransceiverDirection.SendOnly: 'sendonly', | ||
TransceiverDirection.RecvOnly: 'recvonly', | ||
TransceiverDirection.Inactive: 'inactive', | ||
}; | ||
|
||
RTCIceConnectionState iceConnectionStateForString(String? state) { | ||
switch (state) { | ||
case 'new': | ||
return RTCIceConnectionState.RTCIceConnectionStateNew; | ||
case 'checking': | ||
return RTCIceConnectionState.RTCIceConnectionStateChecking; | ||
case 'connected': | ||
return RTCIceConnectionState.RTCIceConnectionStateConnected; | ||
case 'completed': | ||
return RTCIceConnectionState.RTCIceConnectionStateCompleted; | ||
case 'failed': | ||
return RTCIceConnectionState.RTCIceConnectionStateFailed; | ||
case 'disconnected': | ||
return RTCIceConnectionState.RTCIceConnectionStateDisconnected; | ||
case 'closed': | ||
return RTCIceConnectionState.RTCIceConnectionStateClosed; | ||
case 'count': | ||
return RTCIceConnectionState.RTCIceConnectionStateCount; | ||
} | ||
return RTCIceConnectionState.RTCIceConnectionStateClosed; | ||
} | ||
|
||
RTCIceGatheringState iceGatheringStateforString(String? state) { | ||
switch (state) { | ||
case 'new': | ||
return RTCIceGatheringState.RTCIceGatheringStateNew; | ||
case 'gathering': | ||
return RTCIceGatheringState.RTCIceGatheringStateGathering; | ||
case 'complete': | ||
return RTCIceGatheringState.RTCIceGatheringStateComplete; | ||
} | ||
return RTCIceGatheringState.RTCIceGatheringStateNew; | ||
} | ||
|
||
RTCSignalingState signalingStateForString(String? state) { | ||
switch (state) { | ||
case 'stable': | ||
return RTCSignalingState.RTCSignalingStateStable; | ||
case 'have-local-offer': | ||
return RTCSignalingState.RTCSignalingStateHaveLocalOffer; | ||
case 'have-local-pranswer': | ||
return RTCSignalingState.RTCSignalingStateHaveLocalPrAnswer; | ||
case 'have-remote-offer': | ||
return RTCSignalingState.RTCSignalingStateHaveRemoteOffer; | ||
case 'have-remote-pranswer': | ||
return RTCSignalingState.RTCSignalingStateHaveRemotePrAnswer; | ||
case 'closed': | ||
return RTCSignalingState.RTCSignalingStateClosed; | ||
} | ||
return RTCSignalingState.RTCSignalingStateClosed; | ||
} | ||
|
||
RTCDataChannelState rtcDataChannelStateForString(String state) { | ||
switch (state) { | ||
case 'connecting': | ||
return RTCDataChannelState.RTCDataChannelConnecting; | ||
case 'open': | ||
return RTCDataChannelState.RTCDataChannelOpen; | ||
case 'closing': | ||
return RTCDataChannelState.RTCDataChannelClosing; | ||
case 'closed': | ||
return RTCDataChannelState.RTCDataChannelClosed; | ||
} | ||
return RTCDataChannelState.RTCDataChannelClosed; | ||
} | ||
|
||
RTCPeerConnectionState peerConnectionStateForString(String? state) { | ||
switch (state) { | ||
case 'new': | ||
return RTCPeerConnectionState.RTCPeerConnectionStateNew; | ||
case 'connecting': | ||
return RTCPeerConnectionState.RTCPeerConnectionStateConnecting; | ||
case 'connected': | ||
return RTCPeerConnectionState.RTCPeerConnectionStateConnected; | ||
case 'closed': | ||
return RTCPeerConnectionState.RTCPeerConnectionStateClosed; | ||
case 'disconnected': | ||
return RTCPeerConnectionState.RTCPeerConnectionStateDisconnected; | ||
case 'failed': | ||
return RTCPeerConnectionState.RTCPeerConnectionStateFailed; | ||
} | ||
|
||
return RTCPeerConnectionState.RTCPeerConnectionStateClosed; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'media_stream.dart'; | ||
import 'navigator.dart'; | ||
import 'rtc_peerconnection.dart'; | ||
|
||
abstract class RTCFactory { | ||
Future<RTCPeerConnection> createPeerConnection( | ||
Map<String, dynamic> configuration, | ||
[Map<String, dynamic> constraints]); | ||
|
||
Future<MediaStream> createLocalMediaStream(String label); | ||
|
||
Navigator get navigator; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import 'enums.dart'; | ||
import 'media_stream.dart'; | ||
import 'media_stream_track.dart'; | ||
|
||
abstract class MediaRecorder { | ||
/// For Android use audioChannel param | ||
/// For iOS use audioTrack | ||
Future<void> start( | ||
String path, { | ||
MediaStreamTrack? videoTrack, | ||
RecorderAudioChannel? audioChannel, | ||
}); | ||
|
||
/// Only for Flutter Web | ||
void startWeb( | ||
MediaStream stream, { | ||
Function(dynamic blob, bool isLastOne)? onDataChunk, | ||
String mimeType, | ||
}); | ||
|
||
Future<dynamic> stop(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import 'media_stream_track.dart'; | ||
|
||
typedef MediaTrackCallback = void Function(MediaStreamTrack track); | ||
|
||
///https://w3c.github.io/mediacapture-main/#mediastream | ||
abstract class MediaStream { | ||
MediaStream(this._id, this._ownerTag); | ||
final String _id; | ||
final String _ownerTag; | ||
|
||
/// The event type of this event handler is addtrack. | ||
MediaTrackCallback? onAddTrack; | ||
|
||
/// The event type of this event handler is removetrack. | ||
MediaTrackCallback? onRemoveTrack; | ||
|
||
String get id => _id; | ||
|
||
String get ownerTag => _ownerTag; | ||
|
||
/// The active attribute return true if this [MediaStream] is active and false otherwise. | ||
/// [MediaStream] is considered active if at least one of its [MediaStreamTracks] is not in the [MediaStreamTrack.ended] state. | ||
/// Once every track has ended, the stream's active property becomes false. | ||
bool? get active; | ||
|
||
@deprecated | ||
Future<void> getMediaTracks(); | ||
|
||
/// Adds the given [MediaStreamTrack] to this [MediaStream]. | ||
Future<void> addTrack(MediaStreamTrack track, {bool addToNative = true}); | ||
|
||
/// Removes the given [MediaStreamTrack] object from this [MediaStream]. | ||
Future<void> removeTrack(MediaStreamTrack track, | ||
{bool removeFromNative = true}); | ||
|
||
/// Returns a List [MediaStreamTrack] objects representing all the tracks in this stream. | ||
List<MediaStreamTrack> getTracks(); | ||
|
||
/// Returns a List [MediaStreamTrack] objects representing the audio tracks in this stream. | ||
/// The list represents a snapshot of all the [MediaStreamTrack] objects in this stream's track set whose kind is equal to 'audio'. | ||
List<MediaStreamTrack> getAudioTracks(); | ||
|
||
/// Returns a List [MediaStreamTrack] objects representing the video tracks in this stream. | ||
/// The list represents a snapshot of all the [MediaStreamTrack] objects in this stream's track set whose kind is equal to 'video'. | ||
List<MediaStreamTrack> getVideoTracks(); | ||
|
||
/// Returns either a [MediaStreamTrack] object from this stream's track set whose id is equal to trackId, or [StateError], if no such track exists. | ||
MediaStreamTrack? getTrackById(String trackId) { | ||
for (var item in getTracks()) { | ||
if (item.id == trackId) { | ||
return item; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
/// Clones the given [MediaStream] and all its tracks. | ||
MediaStream clone(); | ||
|
||
Future<void> dispose() async { | ||
return Future.value(); | ||
} | ||
} |
Oops, something went wrong.