├── .github ├── FUNDING.yml └── workflows │ └── build.yml ├── .gitignore ├── .gitmodules ├── LICENSE ├── README.md ├── docs ├── AOSP.md ├── Deploy.md ├── Design.md ├── Docker.md ├── Learning.md ├── MI5S.md ├── NetworkTopology.md ├── Protocol.md ├── TODO.md ├── WebRTC.md ├── certs │ ├── ca.crt │ ├── ca.key │ ├── ca.srl │ ├── server.crt │ ├── server.csr │ ├── server.ext │ ├── server.key │ └── server.p12 ├── etc │ ├── nginx.conf │ └── taoyao-signal-server.service ├── image │ ├── android.jpg │ └── web.jpg ├── taoyao-v1.0.zip └── 架构.drawio ├── taoyao-client-android ├── README.md └── taoyao │ ├── .gitignore │ ├── boot │ ├── build.gradle │ ├── consumer-rules.pro │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── acgist │ │ └── taoyao │ │ └── boot │ │ ├── model │ │ ├── Header.java │ │ ├── Message.java │ │ └── MessageCode.java │ │ └── utils │ │ ├── CloseableUtils.java │ │ ├── DateUtils.java │ │ ├── IdUtils.java │ │ ├── JSONUtils.java │ │ ├── MapUtils.java │ │ └── PointerUtils.java │ ├── build.gradle │ ├── client │ ├── build.gradle │ ├── consumer-rules.pro │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── ic_launcher-playstore.png │ │ ├── java │ │ └── com │ │ │ └── acgist │ │ │ └── taoyao │ │ │ └── client │ │ │ ├── MainActivity.java │ │ │ ├── MediaService.java │ │ │ ├── SettingsActivity.java │ │ │ ├── TaoyaoReceiver.java │ │ │ └── signal │ │ │ └── Taoyao.java │ │ └── res │ │ ├── drawable │ │ ├── action.xml │ │ ├── photograph.xml │ │ ├── record.xml │ │ └── settings.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ └── activity_settings.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ ├── ic_launcher_foreground.png │ │ └── ic_launcher_round.png │ │ ├── values │ │ ├── colors.xml │ │ ├── settings.xml │ │ ├── strings.xml │ │ └── themes.xml │ │ └── xml │ │ ├── backup_rules.xml │ │ └── data_extraction_rules.xml │ ├── gradle.properties │ ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── media │ ├── CMakeLists.txt │ ├── build.gradle │ ├── consumer-rules.pro │ ├── libs │ │ └── arm64-v8a │ │ │ └── libjingle_peerconnection_so.so │ ├── proguard-rules.pro │ └── src │ │ └── main │ │ ├── AndroidManifest.xml │ │ ├── cpp │ │ ├── include │ │ │ ├── Log.hpp │ │ │ ├── MediaManager.hpp │ │ │ ├── Room.hpp │ │ │ └── RouterCallback.hpp │ │ └── webrtc │ │ │ ├── MediaManager.cpp │ │ │ ├── Room.cpp │ │ │ └── RouterCallback.cpp │ │ └── java │ │ ├── com │ │ └── acgist │ │ │ └── taoyao │ │ │ └── media │ │ │ ├── MediaManager.java │ │ │ ├── RouterCallback.java │ │ │ ├── VideoSourceType.java │ │ │ ├── audio │ │ │ └── MixerProcesser.java │ │ │ ├── client │ │ │ ├── Client.java │ │ │ ├── CloseableClient.java │ │ │ ├── LocalClient.java │ │ │ ├── PhotographClient.java │ │ │ ├── RecordClient.java │ │ │ ├── RemoteClient.java │ │ │ ├── Room.java │ │ │ ├── RoomClient.java │ │ │ └── SessionClient.java │ │ │ ├── config │ │ │ ├── Config.java │ │ │ ├── MediaAudioProperties.java │ │ │ ├── MediaProperties.java │ │ │ ├── MediaVideoProperties.java │ │ │ ├── WebrtcProperties.java │ │ │ ├── WebrtcStunProperties.java │ │ │ └── WebrtcTurnProperties.java │ │ │ ├── signal │ │ │ ├── ITaoyao.java │ │ │ └── ITaoyaoListener.java │ │ │ └── video │ │ │ ├── AiProcesser.java │ │ │ ├── VideoProcesser.java │ │ │ └── WatermarkProcesser.java │ │ └── org │ │ └── webrtc │ │ ├── AddIceObserver.java │ │ ├── AndroidVideoDecoder.java │ │ ├── AudioDecoderFactoryFactory.java │ │ ├── AudioEncoderFactoryFactory.java │ │ ├── AudioProcessingFactory.java │ │ ├── AudioSource.java │ │ ├── AudioTrack.java │ │ ├── BaseBitrateAdjuster.java │ │ ├── BitrateAdjuster.java │ │ ├── BuiltinAudioDecoderFactoryFactory.java │ │ ├── BuiltinAudioEncoderFactoryFactory.java │ │ ├── CallSessionFileRotatingLogSink.java │ │ ├── CalledByNative.java │ │ ├── CalledByNativeUnchecked.java │ │ ├── Camera1Capturer.java │ │ ├── Camera1Enumerator.java │ │ ├── Camera1Session.java │ │ ├── Camera2Capturer.java │ │ ├── Camera2Enumerator.java │ │ ├── Camera2Session.java │ │ ├── CameraCapturer.java │ │ ├── CameraEnumerationAndroid.java │ │ ├── CameraEnumerator.java │ │ ├── CameraSession.java │ │ ├── CameraVideoCapturer.java │ │ ├── CandidatePairChangeEvent.java │ │ ├── CapturerObserver.java │ │ ├── ContextUtils.java │ │ ├── CryptoOptions.java │ │ ├── DataChannel.java │ │ ├── DefaultVideoDecoderFactory.java │ │ ├── DefaultVideoEncoderFactory.java │ │ ├── DtmfSender.java │ │ ├── DynamicBitrateAdjuster.java │ │ ├── EglBase.java │ │ ├── EglBase10.java │ │ ├── EglBase10Impl.java │ │ ├── EglBase14.java │ │ ├── EglBase14Impl.java │ │ ├── EglRenderer.java │ │ ├── Empty.java │ │ ├── EncodedImage.java │ │ ├── FecControllerFactoryFactoryInterface.java │ │ ├── FileVideoCapturer.java │ │ ├── FrameDecryptor.java │ │ ├── FrameEncryptor.java │ │ ├── FramerateBitrateAdjuster.java │ │ ├── GlGenericDrawer.java │ │ ├── GlRectDrawer.java │ │ ├── GlShader.java │ │ ├── GlTextureFrameBuffer.java │ │ ├── GlUtil.java │ │ ├── H264Utils.java │ │ ├── HardwareVideoDecoderFactory.java │ │ ├── HardwareVideoEncoder.java │ │ ├── HardwareVideoEncoderFactory.java │ │ ├── Histogram.java │ │ ├── IceCandidate.java │ │ ├── JNILogging.java │ │ ├── JavaI420Buffer.java │ │ ├── JniCommon.java │ │ ├── JniHelper.java │ │ ├── LibaomAv1Decoder.java │ │ ├── LibaomAv1Encoder.java │ │ ├── LibvpxVp8Decoder.java │ │ ├── LibvpxVp8Encoder.java │ │ ├── LibvpxVp9Decoder.java │ │ ├── LibvpxVp9Encoder.java │ │ ├── Loggable.java │ │ ├── Logging.java │ │ ├── MediaCodecUtils.java │ │ ├── MediaCodecVideoDecoderFactory.java │ │ ├── MediaCodecWrapper.java │ │ ├── MediaCodecWrapperFactory.java │ │ ├── MediaCodecWrapperFactoryImpl.java │ │ ├── MediaConstraints.java │ │ ├── MediaSource.java │ │ ├── MediaStream.java │ │ ├── MediaStreamTrack.java │ │ ├── Metrics.java │ │ ├── NV12Buffer.java │ │ ├── NV21Buffer.java │ │ ├── NativeAndroidVideoTrackSource.java │ │ ├── NativeCapturerObserver.java │ │ ├── NativeLibrary.java │ │ ├── NativeLibraryLoader.java │ │ ├── NativePeerConnectionFactory.java │ │ ├── NetEqFactoryFactory.java │ │ ├── NetworkChangeDetector.java │ │ ├── NetworkChangeDetectorFactory.java │ │ ├── NetworkControllerFactoryFactory.java │ │ ├── NetworkMonitor.java │ │ ├── NetworkMonitorAutoDetect.java │ │ ├── NetworkPreference.java │ │ ├── NetworkStatePredictorFactoryFactory.java │ │ ├── PeerConnection.java │ │ ├── PeerConnectionDependencies.java │ │ ├── PeerConnectionFactory.java │ │ ├── PlatformSoftwareVideoDecoderFactory.java │ │ ├── Predicate.java │ │ ├── Priority.java │ │ ├── RTCStats.java │ │ ├── RTCStatsCollectorCallback.java │ │ ├── RTCStatsReport.java │ │ ├── RefCountDelegate.java │ │ ├── RefCounted.java │ │ ├── RendererCommon.java │ │ ├── RtcCertificatePem.java │ │ ├── RtpParameters.java │ │ ├── RtpReceiver.java │ │ ├── RtpSender.java │ │ ├── RtpTransceiver.java │ │ ├── SSLCertificateVerifier.java │ │ ├── ScreenCapturerAndroid.java │ │ ├── SdpObserver.java │ │ ├── SessionDescription.java │ │ ├── Size.java │ │ ├── SoftwareVideoDecoderFactory.java │ │ ├── SoftwareVideoEncoderFactory.java │ │ ├── StatsObserver.java │ │ ├── StatsReport.java │ │ ├── SurfaceEglRenderer.java │ │ ├── SurfaceTextureHelper.java │ │ ├── SurfaceViewRenderer.java │ │ ├── TextureBufferImpl.java │ │ ├── ThreadUtils.java │ │ ├── TimestampAligner.java │ │ ├── TurnCustomizer.java │ │ ├── VideoCapturer.java │ │ ├── VideoCodecInfo.java │ │ ├── VideoCodecMimeType.java │ │ ├── VideoCodecStatus.java │ │ ├── VideoDecoder.java │ │ ├── VideoDecoderFactory.java │ │ ├── VideoDecoderFallback.java │ │ ├── VideoDecoderWrapper.java │ │ ├── VideoEncoder.java │ │ ├── VideoEncoderFactory.java │ │ ├── VideoEncoderFallback.java │ │ ├── VideoEncoderWrapper.java │ │ ├── VideoFileRenderer.java │ │ ├── VideoFrame.java │ │ ├── VideoFrameBufferType.java │ │ ├── VideoFrameDrawer.java │ │ ├── VideoProcessor.java │ │ ├── VideoSink.java │ │ ├── VideoSource.java │ │ ├── VideoTrack.java │ │ ├── WebRtcClassLoader.java │ │ ├── WrappedNativeI420Buffer.java │ │ ├── WrappedNativeVideoDecoder.java │ │ ├── WrappedNativeVideoEncoder.java │ │ ├── YuvConverter.java │ │ ├── YuvHelper.java │ │ ├── audio │ │ ├── AudioDeviceModule.java │ │ ├── JavaAudioDeviceModule.java │ │ ├── LegacyAudioDeviceModule.java │ │ ├── LowLatencyAudioBufferManager.java │ │ ├── VolumeLogger.java │ │ ├── WebRtcAudioEffects.java │ │ ├── WebRtcAudioManager.java │ │ ├── WebRtcAudioRecord.java │ │ ├── WebRtcAudioTrack.java │ │ └── WebRtcAudioUtils.java │ │ └── voiceengine │ │ ├── BuildInfo.java │ │ ├── WebRtcAudioEffects.java │ │ ├── WebRtcAudioManager.java │ │ ├── WebRtcAudioRecord.java │ │ ├── WebRtcAudioTrack.java │ │ └── WebRtcAudioUtils.java │ └── settings.gradle ├── taoyao-client-media ├── .env ├── .env.node-a ├── .env.node-b ├── .env.prd ├── .env.work ├── README.md ├── ecosystem.config.cluster.json ├── ecosystem.config.json ├── package.json └── src │ ├── Config.js │ ├── Server.js │ └── Taoyao.js ├── taoyao-client-web ├── README.md ├── favicon.ico ├── index.html ├── package.json ├── public │ ├── taoyao.svg │ ├── taoyao.ttf │ └── taoyao.woff ├── src │ ├── App.vue │ ├── assets │ │ ├── base.css │ │ ├── font.css │ │ └── main.css │ ├── certs │ │ ├── server.crt │ │ └── server.key │ ├── components │ │ ├── Config.js │ │ ├── LocalClient.vue │ │ ├── RemoteClient.vue │ │ ├── SessionClient.vue │ │ └── Taoyao.js │ └── main.js └── vite.config.js └── taoyao-signal-server ├── README.md ├── docs ├── assembly │ ├── dev.xml │ └── prd.xml └── bin │ ├── deploy.sh │ ├── startup.sh │ ├── stop.sh │ └── wait.sh ├── pom.xml ├── taoyao-boot ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── acgist │ │ │ └── taoyao │ │ │ └── boot │ │ │ ├── annotation │ │ │ ├── Description.java │ │ │ ├── Listener.java │ │ │ ├── Manager.java │ │ │ └── Protocol.java │ │ │ ├── config │ │ │ ├── Constant.java │ │ │ ├── FfmpegProperties.java │ │ │ ├── IdProperties.java │ │ │ ├── MediaAudioProperties.java │ │ │ ├── MediaProperties.java │ │ │ ├── MediaVideoProperties.java │ │ │ ├── RewriteProperties.java │ │ │ ├── RewriteRuleProperties.java │ │ │ ├── ScriptProperties.java │ │ │ ├── SecurityProperties.java │ │ │ ├── SocketProperties.java │ │ │ ├── TaoyaoProperties.java │ │ │ ├── WebrtcProperties.java │ │ │ ├── WebrtcStunProperties.java │ │ │ └── WebrtcTurnProperties.java │ │ │ ├── configuration │ │ │ ├── BootAutoConfiguration.java │ │ │ ├── SpringDocAutoConfiguration.java │ │ │ └── WebMvcConfigurerAutoConfiguration.java │ │ │ ├── controller │ │ │ ├── TaoyaoControllerAdvice.java │ │ │ └── TaoyaoErrorController.java │ │ │ ├── interceptor │ │ │ └── InterceptorAdapter.java │ │ │ ├── model │ │ │ ├── Header.java │ │ │ ├── Message.java │ │ │ ├── MessageCode.java │ │ │ ├── MessageCodeException.java │ │ │ └── MessageMapstruct.java │ │ │ ├── runner │ │ │ └── OrderedCommandLineRunner.java │ │ │ ├── service │ │ │ ├── IdService.java │ │ │ └── impl │ │ │ │ └── IdServiceImpl.java │ │ │ └── utils │ │ │ ├── CloseableUtils.java │ │ │ ├── DateUtils.java │ │ │ ├── ErrorUtils.java │ │ │ ├── FileUtils.java │ │ │ ├── HTTPUtils.java │ │ │ ├── JSONUtils.java │ │ │ ├── MapUtils.java │ │ │ ├── NetUtils.java │ │ │ └── ScriptUtils.java │ └── resources │ │ ├── META-INF │ │ └── spring │ │ │ └── org.springframework.boot.autoconfigure.AutoConfiguration.imports │ │ ├── banner.txt │ │ └── logback-spring.xml │ └── test │ └── java │ └── com │ └── acgist │ └── taoyao │ └── boot │ ├── model │ └── MessageTest.java │ └── utils │ ├── FileUtilsTest.java │ ├── HTTPUtilsTest.java │ ├── NetUtilsTest.java │ └── ScriptUtilsTest.java ├── taoyao-server ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── acgist │ │ │ └── taoyao │ │ │ ├── configuration │ │ │ └── TaoyaoAutoConfiguration.java │ │ │ ├── controller │ │ │ ├── ConfigController.java │ │ │ ├── PlatformController.java │ │ │ └── SystemController.java │ │ │ ├── interceptor │ │ │ ├── SecurityInterceptor.java │ │ │ └── SlowInterceptor.java │ │ │ ├── listener │ │ │ ├── QnjrcmzListener.java │ │ │ └── ThyjxcfListener.java │ │ │ └── main │ │ │ └── TaoyaoApplication.java │ └── resources │ │ ├── META-INF │ │ └── spring.factories │ │ ├── application-dev.yml │ │ ├── application-prd.yml │ │ ├── application-win.yml │ │ ├── application.yml │ │ ├── server.p12 │ │ └── static │ │ ├── favicon.ico │ │ └── index.html │ └── test │ └── java │ └── com │ └── acgist │ └── taoyao │ ├── AudioMixerTest.java │ ├── RecorderTest.java │ ├── annotation │ ├── CostedTest.java │ ├── CostedTestTestExecutionListener.java │ └── TaoyaoTest.java │ ├── rtp │ └── RtpTest.java │ └── service │ └── IdServiceTest.java └── taoyao-signal ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── acgist │ │ └── taoyao │ │ └── signal │ │ ├── client │ │ ├── Client.java │ │ ├── ClientAdapter.java │ │ ├── ClientManager.java │ │ ├── ClientMapstruct.java │ │ ├── ClientStatus.java │ │ ├── ClientType.java │ │ ├── proxy │ │ │ └── ProxyClient.java │ │ ├── socket │ │ │ ├── SocketClient.java │ │ │ ├── SocketSignal.java │ │ │ ├── SocketSignalAcceptHandler.java │ │ │ └── SocketSignalMessageHandler.java │ │ └── websocket │ │ │ ├── WebSocketClient.java │ │ │ ├── WebSocketSignal.java │ │ │ └── WebSocketSignalConfigurator.java │ │ ├── configuration │ │ ├── ScriptAutoConfiguration.java │ │ ├── SignalAutoConfiguration.java │ │ ├── SocketSignalAutoConfiguration.java │ │ └── WebSocketSignalAutoConfiguration.java │ │ ├── controller │ │ ├── ClientController.java │ │ ├── ControlController.java │ │ ├── ProtocolController.java │ │ └── RoomController.java │ │ ├── event │ │ ├── ApplicationEventAdapter.java │ │ ├── ClientEventAdapter.java │ │ ├── EventPublisher.java │ │ ├── RoomEventAdapter.java │ │ ├── SessionEventAdapter.java │ │ ├── client │ │ │ ├── ClientCloseEvent.java │ │ │ ├── ClientConfigEvent.java │ │ │ ├── ClientOfflineEvent.java │ │ │ └── ClientOnlineEvent.java │ │ ├── media │ │ │ ├── MediaConsumeEvent.java │ │ │ ├── MediaConsumerCloseEvent.java │ │ │ ├── MediaConsumerPauseEvent.java │ │ │ ├── MediaConsumerResumeEvent.java │ │ │ ├── MediaDataConsumerCloseEvent.java │ │ │ ├── MediaDataProducerCloseEvent.java │ │ │ ├── MediaProducerCloseEvent.java │ │ │ ├── MediaProducerPauseEvent.java │ │ │ ├── MediaProducerResumeEvent.java │ │ │ └── TransportCloseEvent.java │ │ ├── room │ │ │ ├── MediaServerRegisterEvent.java │ │ │ ├── RecorderCloseEvent.java │ │ │ ├── RoomCloseEvent.java │ │ │ ├── RoomEnterEvent.java │ │ │ └── RoomLeaveEvent.java │ │ └── session │ │ │ └── SessionCloseEvent.java │ │ ├── party │ │ ├── media │ │ │ ├── Consumer.java │ │ │ ├── DataConsumer.java │ │ │ ├── DataProducer.java │ │ │ ├── Kind.java │ │ │ ├── Operator.java │ │ │ ├── OperatorAdapter.java │ │ │ ├── Producer.java │ │ │ └── Transport.java │ │ ├── package-info.java │ │ ├── room │ │ │ ├── ClientWrapper.java │ │ │ ├── Recorder.java │ │ │ ├── Room.java │ │ │ ├── RoomClientId.java │ │ │ ├── RoomManager.java │ │ │ ├── RoomStatus.java │ │ │ ├── RoomStatusMapstruct.java │ │ │ └── SubscribeType.java │ │ └── session │ │ │ ├── Session.java │ │ │ └── SessionManager.java │ │ ├── protocol │ │ ├── Protocol.java │ │ ├── ProtocolAdapter.java │ │ ├── ProtocolClientAdapter.java │ │ ├── ProtocolControlAdapter.java │ │ ├── ProtocolManager.java │ │ ├── ProtocolRoomAdapter.java │ │ ├── ProtocolSessionAdapter.java │ │ ├── client │ │ │ ├── ClientAlarmProtocol.java │ │ │ ├── ClientBroadcastProtocol.java │ │ │ ├── ClientCloseProtocol.java │ │ │ ├── ClientConfigProtocol.java │ │ │ ├── ClientHeartbeatProtocol.java │ │ │ ├── ClientListProtocol.java │ │ │ ├── ClientOfflineProtocol.java │ │ │ ├── ClientOnlineProtocol.java │ │ │ ├── ClientRebootProtocol.java │ │ │ ├── ClientRegisterProtocol.java │ │ │ ├── ClientShutdownProtocol.java │ │ │ ├── ClientStatusProtocol.java │ │ │ └── ClientUnicastProtocol.java │ │ ├── control │ │ │ ├── ControlBellProtocol.java │ │ │ ├── ControlClientRecordProtocol.java │ │ │ ├── ControlConfigAudioProtocol.java │ │ │ ├── ControlConfigVideoProtocol.java │ │ │ ├── ControlPhotographProtocol.java │ │ │ ├── ControlServerRecordProtocol.java │ │ │ ├── ControlWakeupProtocol.java │ │ │ ├── IControlBellProtocol.java │ │ │ ├── IControlClientRecordProtocol.java │ │ │ ├── IControlConfigAudioProtocol.java │ │ │ ├── IControlConfigVideoProtocol.java │ │ │ ├── IControlPhotographProtocol.java │ │ │ ├── IControlServerRecordProtocol.java │ │ │ └── IControlWakeupProtocol.java │ │ ├── media │ │ │ ├── MediaAudioVolumeProtocol.java │ │ │ ├── MediaConsumeProtocol.java │ │ │ ├── MediaConsumerCloseProtocol.java │ │ │ ├── MediaConsumerLayersChangeProtocol.java │ │ │ ├── MediaConsumerPauseProtocol.java │ │ │ ├── MediaConsumerRequestKeyFrameProtocol.java │ │ │ ├── MediaConsumerResumeProtocol.java │ │ │ ├── MediaConsumerScoreProtocol.java │ │ │ ├── MediaConsumerSetPreferredLayersProtocol.java │ │ │ ├── MediaConsumerSetPriorityProtocol.java │ │ │ ├── MediaConsumerStatusProtocol.java │ │ │ ├── MediaDataConsumeProtocol.java │ │ │ ├── MediaDataConsumerCloseProtocol.java │ │ │ ├── MediaDataConsumerStatusProtocol.java │ │ │ ├── MediaDataProduceProtocol.java │ │ │ ├── MediaDataProducerCloseProtocol.java │ │ │ ├── MediaDataProducerStatusProtocol.java │ │ │ ├── MediaIceRestartProtocol.java │ │ │ ├── MediaProduceProtocol.java │ │ │ ├── MediaProducerCloseProtocol.java │ │ │ ├── MediaProducerPauseProtocol.java │ │ │ ├── MediaProducerResumeProtocol.java │ │ │ ├── MediaProducerScoreProtocol.java │ │ │ ├── MediaProducerStatusProtocol.java │ │ │ ├── MediaRouterRtpCapabilitiesProtocol.java │ │ │ ├── MediaTransportCloseProtocol.java │ │ │ ├── MediaTransportPlainCreateProtocol.java │ │ │ ├── MediaTransportStatusProtocol.java │ │ │ ├── MediaTransportWebRtcConnectProtocol.java │ │ │ ├── MediaTransportWebRtcCreateProtocol.java │ │ │ └── MediaVideoOrientationChangeProtocol.java │ │ ├── platform │ │ │ ├── PlatformErrorProtocol.java │ │ │ ├── PlatformRebootProtocol.java │ │ │ ├── PlatformScriptProtocol.java │ │ │ └── PlatformShutdownProtocol.java │ │ ├── room │ │ │ ├── RoomBroadcastProtocol.java │ │ │ ├── RoomClientListIdProtocol.java │ │ │ ├── RoomClientListProtocol.java │ │ │ ├── RoomCloseProtocol.java │ │ │ ├── RoomCreateProtocol.java │ │ │ ├── RoomEnterProtocol.java │ │ │ ├── RoomExpelProtocol.java │ │ │ ├── RoomInviteProtocol.java │ │ │ ├── RoomLeaveProtocol.java │ │ │ ├── RoomListProtocol.java │ │ │ └── RoomStatusProtocol.java │ │ ├── session │ │ │ ├── SessionCallProtocol.java │ │ │ ├── SessionCloseProtocol.java │ │ │ ├── SessionExchangeProtocol.java │ │ │ ├── SessionPauseProtocol.java │ │ │ └── SessionResumeProtocol.java │ │ └── system │ │ │ ├── SystemInfoProtocol.java │ │ │ ├── SystemRebootProtocol.java │ │ │ └── SystemShutdownProtocol.java │ │ ├── service │ │ ├── SecurityService.java │ │ ├── UsernamePasswordService.java │ │ └── impl │ │ │ └── SecurityServiceImpl.java │ │ └── utils │ │ └── CipherUtils.java └── resources │ └── META-INF │ └── spring │ └── org.springframework.boot.autoconfigure.AutoConfiguration.imports └── test └── java └── com └── acgist └── taoyao └── signal └── utils └── CipherUtilsTest.java /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # github: [acgist] 2 | custom: ["https://www.acgist.com/sponsor"] 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .project 2 | .settings 3 | .classpath 4 | .factorypath 5 | 6 | dist 7 | logs 8 | build 9 | target 10 | node_modules 11 | 12 | .vscode 13 | 14 | package-lock.json 15 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "taoyao-client-media/mediasoup"] 2 | path = taoyao-client-media/mediasoup 3 | url = https://github.com/versatica/mediasoup.git 4 | [submodule "taoyao-client-web/mediasoup-client"] 5 | path = taoyao-client-web/mediasoup-client 6 | url = https://github.com/versatica/mediasoup-client.git 7 | [submodule "taoyao-client-android/libmediasoupclient"] 8 | path = taoyao-client-android/libmediasoupclient 9 | url = https://github.com/versatica/libmediasoupclient.git 10 | -------------------------------------------------------------------------------- /docs/Learning.md: -------------------------------------------------------------------------------- 1 | # 资料 2 | 3 | ## WebRTC资料 4 | 5 | * https://www.cnblogs.com/ssyfj/p/14828185.html 6 | * https://www.cnblogs.com/ssyfj/p/14826516.html 7 | * https://www.cnblogs.com/ssyfj/p/14823861.html 8 | * https://www.cnblogs.com/ssyfj/p/14815266.html 9 | * https://www.cnblogs.com/ssyfj/p/14811253.html 10 | * https://www.cnblogs.com/ssyfj/p/14806678.html 11 | * https://www.cnblogs.com/ssyfj/p/14805040.html 12 | * https://www.cnblogs.com/ssyfj/p/14788663.html 13 | * https://www.cnblogs.com/ssyfj/p/14787012.html 14 | * https://www.cnblogs.com/ssyfj/p/14783168.html 15 | * https://www.cnblogs.com/ssyfj/p/14781982.html 16 | * https://www.cnblogs.com/ssyfj/p/14778839.html 17 | 18 | ## Mediasoup资料 19 | 20 | * https://www.cnblogs.com/ssyfj/p/14855454.html 21 | * https://www.cnblogs.com/ssyfj/p/14851442.html 22 | * https://www.cnblogs.com/ssyfj/p/14850041.html 23 | * https://www.cnblogs.com/ssyfj/p/14847097.html 24 | * https://www.cnblogs.com/ssyfj/p/14843182.html 25 | * https://www.cnblogs.com/ssyfj/p/14843082.html 26 | 27 | ## 更多资料 28 | 29 | * https://zhuanlan.zhihu.com/p/466172240 30 | * http://koca.szkingdom.com/forum/t/topic/218 31 | * https://blog.csdn.net/qw225967/article/details/121251305 32 | * http://www.manoner.com/post/音视频基础/WebRTC核心组件和协议栈/ 33 | * https://blog.csdn.net/ababab12345/article/details/115585378 34 | * https://blog.csdn.net/jisuanji111111/article/details/121634199 35 | * https://lequ7.com/guan-yu-webrtc-yi-wen-xiang-jie-webrtc-ji-chu.html 36 | -------------------------------------------------------------------------------- /docs/MI5S.md: -------------------------------------------------------------------------------- 1 | # 小米5S 2 | 3 | 由于使用小米5S作为测试机,没有适合的`LineageOS`版本,所有这里选择了`PixelExperience`作为测试系统。如果其他机器建议使用`LineageOS`,当然最好还是使用`Pixel`作为测试机,可以直接使用原生系统,或者自己定制编译`AOSP`。 4 | 5 | ## TWRP 6 | 7 | * https://twrp.me/Devices/ 8 | 9 | ## MIUI 10 | 11 | * 卡刷:http://bigota.d.miui.com/V11.0.2.0.OAGCNXM/miui_MI5S_V11.0.2.0.OAGCNXM_6ce204eb2c_8.0.zip 12 | * 线刷:http://bigota.d.miui.com/V11.0.2.0.OAGCNXM/capricorn_images_V11.0.2.0.OAGCNXM_20191023.0000.00_8.0_cn_714988e4b7.tgz 13 | * 文章:https://web.vip.miui.com/page/info/mio/mio/detail?isTop=0&postId=17843063 14 | 15 | ## PixelExperience 16 | 17 | * https://get.pixelexperience.org/capricorn 18 | 19 | ## 砖头 20 | 21 | 如果刷机过程中出现了黑屏,进不了`recovery`和`bootloader`时,需要使用`MiFlash`通过串口刷机。 22 | -------------------------------------------------------------------------------- /docs/TODO.md: -------------------------------------------------------------------------------- 1 | # 计划任务 2 | 3 | ## 日常任务 4 | 5 | * 过时方法 6 | * 注释优化:详细描述、单位描述 7 | * 日志优化: 8 | * 添加测试: 9 | * 异常优化:捕获范围 10 | * 排版优化:优化顺序 11 | * 代码优化:逻辑调整、性能优化、安全优化、增强稳定性 12 | 13 | ## Mediasoup功能集成 14 | 15 | 持续集成`mediasoup`功能: 16 | 17 | * 上次集成`mediasoup-demo`日期:`2023-06-19` 18 | * 上次集成`libmediasoupclient`日期:`2023-06-19` 19 | 20 | > `mediasoup-demo`包含`mediasoup`和`mediasoup-client` 21 | 22 | ## 计划任务 23 | 24 | * 开机自启 25 | * 录像底噪 26 | * 性能测试 27 | * 稳定性测试 28 | * 分辨率调整 29 | * 安卓内存抖动 30 | * 多重子网环境 31 | * 降低视频录像大小 32 | * 测试时间层和空间层 33 | * 码率等等参数配置验证 34 | * 查询消费者生产者信息 35 | * 存在TURN服务优先使用 36 | * 安卓关闭视频没有删除预览 37 | * 浏览器WebRTC监控页面关闭:`chrome://webrtc-internals/` 38 | 39 | ## 完成任务 40 | -------------------------------------------------------------------------------- /docs/certs/ca.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDjzCCAnegAwIBAgIJAKPjuujtbFnoMA0GCSqGSIb3DQEBCwUAMF4xCzAJBgNV 3 | BAYTAmNuMQswCQYDVQQIDAJnZDELMAkGA1UEBwwCZ3oxDzANBgNVBAoMBmFjZ2lz 4 | dDEPMA0GA1UECwwGYWNnaXN0MRMwEQYDVQQDDAphY2dpc3QuY29tMB4XDTIzMDIy 5 | NzEzMzUyNloXDTMzMDIyNDEzMzUyNlowXjELMAkGA1UEBhMCY24xCzAJBgNVBAgM 6 | AmdkMQswCQYDVQQHDAJnejEPMA0GA1UECgwGYWNnaXN0MQ8wDQYDVQQLDAZhY2dp 7 | c3QxEzARBgNVBAMMCmFjZ2lzdC5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw 8 | ggEKAoIBAQDbt9orZnoTtzbaI9+S8uqqvi8rqOzi+b3tRHOYE+JVQNxWf8vTvKJ5 9 | mDDrBqICVy2SCtwkxXgrjDcRQVKK1IiDqxQ4oY6DCZetx4gQhYk9ychYsPPKnRg8 10 | bQEG48DM1EhmxhozUv7kaiUMS0LNODfzLTH/C25Nhgt3laGCtcIWOQliO9AVOxam 11 | EasfYP01AfL2qahk1s5N7fK9poLpbR9BS8ZUYMxZ5xOIUcc5eithBgGvuHUv9nEY 12 | Dart6XPC4z3YE9liwrxYwcBxztdvCA2EWeh1k0wNcrT/eJG3cuGgzsPDjI/BORq1 13 | DWFKJOXrWmhmIlw+VaQ6PIiD4/aQ50xfAgMBAAGjUDBOMB0GA1UdDgQWBBR98tbO 14 | eDI9mBcuZ96keDld1w54OzAfBgNVHSMEGDAWgBR98tbOeDI9mBcuZ96keDld1w54 15 | OzAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQCavKK+pJCmWDqFNMoX 16 | YwdRPDJS7LoCFV7C8oTkX5myCKNOi11bzlyqP/EkelubtRgaNr+GZCyhwxPiJvRx 17 | ZrWsoWpOH8OEdADM9lU+UXR23Ufmo9jFFEL7jZ9u9OmOJWAM5xM1KqCBd5+KRvfE 18 | oEHXdayfy6l00F+rsgaMm6IKdZcthAxVVEKO60GfwavcuvIiHVVLxW21H8BMoqd6 19 | Erigq7wJRRH+qm7Q5fVpmo1L7E6T2cBvGcFHKuQFdoxDlH4N6tPRDuRSODKFE//O 20 | D1ViQY65nn35mawbz2AgUUPvWiBDYYomeKIiGl859PukeP1jwDZcECFtrhH4s1p+ 21 | at2z 22 | -----END CERTIFICATE----- 23 | -------------------------------------------------------------------------------- /docs/certs/ca.srl: -------------------------------------------------------------------------------- 1 | C75F31B213340862 2 | -------------------------------------------------------------------------------- /docs/certs/server.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIID2TCCAsGgAwIBAgIJAMdfMbITNAhiMA0GCSqGSIb3DQEBCwUAMF4xCzAJBgNV 3 | BAYTAmNuMQswCQYDVQQIDAJnZDELMAkGA1UEBwwCZ3oxDzANBgNVBAoMBmFjZ2lz 4 | dDEPMA0GA1UECwwGYWNnaXN0MRMwEQYDVQQDDAphY2dpc3QuY29tMB4XDTIzMDIy 5 | NzEzMzg0OFoXDTMzMDIyNDEzMzg0OFowZTELMAkGA1UEBhMCY24xCzAJBgNVBAgM 6 | AmdkMQswCQYDVQQHDAJnejEPMA0GA1UECgwGYWNnaXN0MQ8wDQYDVQQLDAZ0YW95 7 | YW8xGjAYBgNVBAMMEXRhb3lhby5hY2dpc3QuY29tMIIBIjANBgkqhkiG9w0BAQEF 8 | AAOCAQ8AMIIBCgKCAQEAmeQvh6OwHR87DKvm04z1xjbHgh6fxi6y+5jMJ7K7LvPT 9 | l+7haNB/eeSgEnHL38Naaw2cQvNkSAVPK210q574tQZW6Am2icRb9EJnMx2tKdaG 10 | 8QtTGxddScebyO++7qzf8CwECPRpsZRRp1a5ompCouDXY4VWJatXBMnZX05ZqUJH 11 | 0u6nioDwvd+YBOui4nGCxoF8tcVsidvHWx0JTfC7simyMp/5VvVYt7V4ENuU+3NT 12 | wDF7sEW1z8Sx1ErE4NLQIyy+PpGmV+h2HgNb0Bnre+jq7v/1Ue2Irsd6xe9iHf3P 13 | ji/mnkrRdAxd36KszFvmQjLAClJM1tRjc7gGyO8yCQIDAQABo4GSMIGPMAsGA1Ud 14 | DwQEAwIF4DAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwYQYDVR0RBFow 15 | WIcEfwAAAYcEwKgBZIcEwKgBbocEwKgIZIcEwKgIboIJbG9jYWxob3N0ggphY2dp 16 | c3QuY29tgg53d3cuYWNnaXN0LmNvbYIRdGFveWFvLmFjZ2lzdC5jb20wDQYJKoZI 17 | hvcNAQELBQADggEBAKDYyUUMFDchfTYwEhUWHHtUpJTzVz2opAoKjUU2yH4pT4dT 18 | Fb1s4NAuopoU9ycX4MJaApmxMioWwQzkoBLbnr+4RPfOYR9nlU0s+dx5JcpOgJtR 19 | 6X08ZDmW2DqhfIqR89uvIOgOU0oc6nUxQ0+doihDYyuyvXkvkZLjl8hrv6phuL8e 20 | qhtx9++4umD3RYbRsASRmB8/iYTgi7WAvFyNM9kkS5pwkJOaHN+vtKx5xpytEROT 21 | pbdUgGdXcYzYwzqDJ7Wbe0pIKeZ97rx6mF+0/92sWhd2U54jn5M1gp1sCQqG/syd 22 | tER+0jG77mvqkls5VCNmUE1+pOa53MvB5TuTTsA= 23 | -----END CERTIFICATE----- 24 | -------------------------------------------------------------------------------- /docs/certs/server.csr: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE REQUEST----- 2 | MIICqjCCAZICAQAwZTELMAkGA1UEBhMCY24xCzAJBgNVBAgMAmdkMQswCQYDVQQH 3 | DAJnejEPMA0GA1UECgwGYWNnaXN0MQ8wDQYDVQQLDAZ0YW95YW8xGjAYBgNVBAMM 4 | EXRhb3lhby5hY2dpc3QuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKC 5 | AQEAmeQvh6OwHR87DKvm04z1xjbHgh6fxi6y+5jMJ7K7LvPTl+7haNB/eeSgEnHL 6 | 38Naaw2cQvNkSAVPK210q574tQZW6Am2icRb9EJnMx2tKdaG8QtTGxddScebyO++ 7 | 7qzf8CwECPRpsZRRp1a5ompCouDXY4VWJatXBMnZX05ZqUJH0u6nioDwvd+YBOui 8 | 4nGCxoF8tcVsidvHWx0JTfC7simyMp/5VvVYt7V4ENuU+3NTwDF7sEW1z8Sx1ErE 9 | 4NLQIyy+PpGmV+h2HgNb0Bnre+jq7v/1Ue2Irsd6xe9iHf3Pji/mnkrRdAxd36Ks 10 | zFvmQjLAClJM1tRjc7gGyO8yCQIDAQABoAAwDQYJKoZIhvcNAQELBQADggEBAC2M 11 | KwMJv8TKM7QL6UE3skEoMhXgxwwODuIBiiloySHmRsb+fVEYcF1f+gN9UxSVwaIx 12 | BP7sb/+xy/N9G+28QVTbVlSc1MneQRPHjlx2MQqRHhfxtJ2/Zf6qFUuR2LimuHth 13 | HwIgQotnUbe6C2630bNeYV5mOyF/rltw0pSoaPlMG9WsNtzZJ1LYzyNp5ztXPR3W 14 | O2MkNQ3ZWqsR7dQXdUJbgruniwfxVGKxab6wBg+GZsHjiHujEmljjt3MIwimVDT+ 15 | Z1V/R8C1Rlk98lJY5hSVBXZ09C5hox9NAvYkGfZ+ZqupOLoPOrvux7zETsDPxzV9 16 | mvAXPwkT0zVn/YvUCvo= 17 | -----END CERTIFICATE REQUEST----- 18 | -------------------------------------------------------------------------------- /docs/certs/server.ext: -------------------------------------------------------------------------------- 1 | keyUsage = nonRepudiation, digitalSignature, keyEncipherment 2 | extendedKeyUsage = serverAuth, clientAuth 3 | subjectAltName=@SubjectAlternativeName 4 | 5 | [ SubjectAlternativeName ] 6 | IP.1=127.0.0.1 7 | IP.2=192.168.1.100 8 | IP.3=192.168.1.110 9 | IP.4=192.168.8.100 10 | IP.5=192.168.8.110 11 | DNS.1=localhost 12 | DNS.2=acgist.com 13 | DNS.3=www.acgist.com 14 | DNS.4=taoyao.acgist.com 15 | -------------------------------------------------------------------------------- /docs/certs/server.p12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/docs/certs/server.p12 -------------------------------------------------------------------------------- /docs/etc/taoyao-signal-server.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=taoyao signal server 3 | After=network.target 4 | Wants=network.target 5 | 6 | [Service] 7 | User=taoyao 8 | Type=forking 9 | KillMode=process 10 | ExecStart=/data/taoyao/taoyao-signal-server/deploy/bin/startup.sh 11 | ExecReload=/bin/kill -HUP $MAINPID 12 | ExecStop=/bin/kill -QUIT $MAINPID 13 | Restart=always 14 | RestartSec=5s 15 | 16 | [Install] 17 | WantedBy=multi-user.target 18 | -------------------------------------------------------------------------------- /docs/image/android.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/docs/image/android.jpg -------------------------------------------------------------------------------- /docs/image/web.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/docs/image/web.jpg -------------------------------------------------------------------------------- /docs/taoyao-v1.0.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/docs/taoyao-v1.0.zip -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/.gitignore: -------------------------------------------------------------------------------- 1 | .cxx 2 | .idea 3 | .gradle 4 | 5 | media/deps 6 | 7 | local.properties 8 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/boot/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | } 4 | 5 | android { 6 | namespace 'com.acgist.client.boot' 7 | compileSdk rootProject.ext.taoyao.compileSdk 8 | defaultConfig { 9 | minSdk rootProject.ext.taoyao.minSdk 10 | targetSdk rootProject.ext.taoyao.targetSdk 11 | consumerProguardFiles "consumer-rules.pro" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled true 16 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | compileOptions { 20 | sourceCompatibility rootProject.ext.taoyao.javaVersion 21 | targetCompatibility rootProject.ext.taoyao.javaVersion 22 | } 23 | } 24 | 25 | dependencies { 26 | api 'org.apache.commons:commons-lang3:3.12.0' 27 | api 'org.apache.commons:commons-collections4:4.4' 28 | api 'com.fasterxml.jackson.core:jackson-databind:2.14.2' 29 | api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.2' 30 | testImplementation 'junit:junit:4.13.2' 31 | } 32 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/boot/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-android/taoyao/boot/consumer-rules.pro -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/boot/proguard-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-android/taoyao/boot/proguard-rules.pro -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/boot/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/boot/src/main/java/com/acgist/taoyao/boot/model/Header.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.model; 2 | 3 | import java.io.Serializable; 4 | 5 | /** 6 | * 消息头部 7 | * 8 | * @author acgist 9 | */ 10 | public class Header implements Cloneable, Serializable { 11 | 12 | private static final long serialVersionUID = 1L; 13 | 14 | /** 15 | * 消息版本 16 | */ 17 | private String v; 18 | /** 19 | * 消息标识 20 | */ 21 | private Long id; 22 | /** 23 | * 信令标识 24 | */ 25 | private String signal; 26 | 27 | public Header() { 28 | } 29 | 30 | public Header(String v, Long id, String signal) { 31 | this.v = v; 32 | this.id = id; 33 | this.signal = signal; 34 | } 35 | 36 | @Override 37 | public Header clone() { 38 | return new Header(this.v, this.id, this.signal); 39 | } 40 | 41 | public String getV() { 42 | return this.v; 43 | } 44 | 45 | public void setV(String v) { 46 | this.v = v; 47 | } 48 | 49 | public Long getId() { 50 | return this.id; 51 | } 52 | 53 | public void setId(Long id) { 54 | this.id = id; 55 | } 56 | 57 | public String getSignal() { 58 | return this.signal; 59 | } 60 | 61 | public void setSignal(String signal) { 62 | this.signal = signal; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/boot/src/main/java/com/acgist/taoyao/boot/utils/CloseableUtils.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.utils; 2 | 3 | import android.util.Log; 4 | 5 | import java.io.Closeable; 6 | 7 | /** 8 | * 关闭资源工具 9 | * 10 | * @author acgist 11 | */ 12 | public final class CloseableUtils { 13 | 14 | private CloseableUtils() { 15 | } 16 | 17 | /** 18 | * 关闭资源 19 | * 20 | * @param closeable 资源 21 | */ 22 | public static final void close(Closeable closeable) { 23 | try { 24 | if (closeable != null) { 25 | closeable.close(); 26 | } 27 | } catch (Exception e) { 28 | Log.e(CloseableUtils.class.getSimpleName(), "关闭资源异常", e); 29 | } 30 | } 31 | 32 | /** 33 | * 关闭资源 34 | * 35 | * @param closeable 资源 36 | */ 37 | public static final void close(AutoCloseable closeable) { 38 | try { 39 | if (closeable != null) { 40 | closeable.close(); 41 | } 42 | } catch (Exception e) { 43 | Log.e(CloseableUtils.class.getSimpleName(), "关闭资源异常", e); 44 | } 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/boot/src/main/java/com/acgist/taoyao/boot/utils/PointerUtils.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.utils; 2 | 3 | import android.util.Log; 4 | 5 | import org.apache.commons.lang3.reflect.FieldUtils; 6 | 7 | import java.lang.reflect.Field; 8 | 9 | /** 10 | * 指针工具 11 | * 12 | * @author acgist 13 | */ 14 | public final class PointerUtils { 15 | 16 | private PointerUtils() { 17 | } 18 | 19 | /** 20 | * @param object 对象 21 | * @param name 指针属性名称 22 | * 23 | * @return 指针 24 | */ 25 | public static final long getNativePointer(Object object, String name) { 26 | if(object == null) { 27 | return 0L; 28 | } 29 | try { 30 | final Field reader = FieldUtils.getField(object.getClass(), name, true); 31 | if(reader == null) { 32 | return 0L; 33 | } 34 | return reader.getLong(object); 35 | } catch (Exception e) { 36 | Log.e(PointerUtils.class.getSimpleName(), "获取指针异常", e); 37 | } 38 | return 0L; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' version '7.4.2' apply false 3 | id 'com.android.application' version '7.4.2' apply false 4 | // 打包体积变大 5 | // id 'com.android.library' version '8.0.1' apply false 6 | // id 'com.android.application' version '8.0.1' apply false 7 | } 8 | ext { 9 | taoyao = [ 10 | minSdk : 28, 11 | targetSdk : 32, 12 | compileSdk : 32, 13 | versionCode : 100, 14 | versionName : "1.0.0", 15 | ndkVersion : "23.1.7779620", 16 | javaVersion : JavaVersion.VERSION_17, 17 | cmakeVersion : "3.22.1", 18 | ] 19 | } -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | } 4 | 5 | android { 6 | namespace 'com.acgist.taoyao.client' 7 | compileSdk rootProject.ext.taoyao.compileSdk 8 | defaultConfig { 9 | minSdk rootProject.ext.taoyao.minSdk 10 | targetSdk rootProject.ext.taoyao.targetSdk 11 | versionCode rootProject.ext.taoyao.versionCode 12 | versionName rootProject.ext.taoyao.versionName 13 | applicationId "com.acgist.taoyao.client" 14 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled true 19 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | compileOptions { 23 | sourceCompatibility rootProject.ext.taoyao.javaVersion 24 | targetCompatibility rootProject.ext.taoyao.javaVersion 25 | } 26 | buildFeatures { 27 | viewBinding true 28 | } 29 | } 30 | 31 | dependencies { 32 | implementation project(path: ':boot') 33 | implementation project(path: ':media') 34 | implementation 'androidx.appcompat:appcompat:1.5.1' 35 | implementation 'androidx.constraintlayout:constraintlayout:2.1.4' 36 | implementation 'com.google.android.material:material:1.8.0' 37 | testImplementation 'junit:junit:4.13.2' 38 | } 39 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-android/taoyao/client/consumer-rules.pro -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/proguard-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-android/taoyao/client/proguard-rules.pro -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/ic_launcher-playstore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-android/taoyao/client/src/main/ic_launcher-playstore.png -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/java/com/acgist/taoyao/client/TaoyaoReceiver.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.client; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.util.Log; 7 | 8 | /** 9 | * 开机广播 10 | * 11 | * @author acgist 12 | */ 13 | public class TaoyaoReceiver extends BroadcastReceiver { 14 | 15 | @Override 16 | public void onReceive(Context context, Intent intent) { 17 | Log.d(TaoyaoReceiver.class.getSimpleName(), "onReceive:" + intent.getAction()); 18 | if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) { 19 | this.bootTaoyao(context); 20 | } else { 21 | } 22 | } 23 | 24 | /** 25 | * 拉起预览 26 | * 27 | * @param context 上下文 28 | */ 29 | private void bootTaoyao(Context context) { 30 | final Intent serviceIntent = new Intent(context, MediaService.class); 31 | serviceIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 32 | serviceIntent.setAction(MediaService.Action.BOOT.name()); 33 | context.startForegroundService(serviceIntent); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/res/drawable/action.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/res/drawable/photograph.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 13 | 14 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/res/drawable/record.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/res/drawable/settings.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-android/taoyao/client/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-android/taoyao/client/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-android/taoyao/client/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-android/taoyao/client/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-android/taoyao/client/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-android/taoyao/client/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-android/taoyao/client/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-android/taoyao/client/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-android/taoyao/client/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-android/taoyao/client/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-android/taoyao/client/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-android/taoyao/client/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-android/taoyao/client/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-android/taoyao/client/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-android/taoyao/client/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFFFFFFF 4 | #FF000000 5 | #FF6200EE 6 | #FF3700B3 7 | #FF03DAC5 8 | #FF018786 9 | 10 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 桃夭 4 | 桃夭终端预览 5 | 桃夭终端设置 6 | 动作 7 | 录像 8 | 设置 9 | 拍照 10 | 连接 11 | 信令端口 12 | 信令地址 13 | 终端名称 14 | 终端标识 15 | 信令帐号 16 | 信令密码 17 | 18 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/res/xml/backup_rules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/client/src/main/res/xml/data_extraction_rules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx512m -Dfile.encoding=UTF-8 2 | android.useAndroidX=true 3 | android.nonTransitiveRClass=true 4 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-android/taoyao/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Mar 20 09:51:37 CST 2023 2 | zipStoreBase=GRADLE_USER_HOME 3 | zipStorePath=wrapper/dists 4 | distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-7.5-bin.zip 5 | #distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip 6 | #distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip 7 | distributionBase=GRADLE_USER_HOME 8 | distributionPath=wrapper/dists 9 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-android/taoyao/media/consumer-rules.pro -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/libs/arm64-v8a/libjingle_peerconnection_so.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-android/taoyao/media/libs/arm64-v8a/libjingle_peerconnection_so.so -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/proguard-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-android/taoyao/media/proguard-rules.pro -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/cpp/include/Log.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | /** 4 | * 日志头文件 5 | */ 6 | namespace acgist { 7 | 8 | #include "android/log.h" 9 | 10 | #ifndef LOG_TAG_TAOYAO 11 | #define LOG_TAG_TAOYAO "libtaoyao" 12 | #define LOG_D(format, ...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG_TAOYAO, "%s " format, __func__, ##__VA_ARGS__) 13 | #define LOG_I(format, ...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG_TAOYAO, "%s " format, __func__, ##__VA_ARGS__) 14 | #define LOG_W(format, ...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG_TAOYAO, "%s " format, __func__, ##__VA_ARGS__) 15 | #define LOG_E(format, ...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG_TAOYAO, "%s " format, __func__, ##__VA_ARGS__) 16 | #endif 17 | 18 | } 19 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/cpp/include/MediaManager.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "jni.h" 4 | #include "Log.hpp" 5 | #include "mediasoupclient.hpp" 6 | 7 | #include "sdk/android/src/jni/jvm.h" 8 | 9 | /** 10 | * 媒体管理器头文件 11 | */ 12 | namespace acgist { 13 | 14 | /** 15 | * 全局JavaVM指针 16 | */ 17 | extern JavaVM* taoyaoJavaVM; 18 | /** 19 | * 绑定Java线程 20 | * 21 | * @param env JNIEnv 22 | * @param name Java线程名称 23 | */ 24 | extern void bindJavaThread(JNIEnv** env, const char* name = "C++Thread"); 25 | /** 26 | * 解绑Java线程 27 | */ 28 | extern void unbindJavaThread(); 29 | 30 | } -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/com/acgist/taoyao/media/VideoSourceType.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.media; 2 | 3 | /** 4 | * 视频来源类型 5 | * 6 | * @author acgist 7 | */ 8 | public enum VideoSourceType { 9 | 10 | /** 11 | * 文件共享:FileVideoCapturer 12 | */ 13 | FILE, 14 | /** 15 | * 后置摄像头:CameraVideoCapturer 16 | */ 17 | BACK, 18 | /** 19 | * 前置摄像头:CameraVideoCapturer 20 | */ 21 | FRONT, 22 | /** 23 | * 屏幕共享:ScreenCapturerAndroid 24 | */ 25 | SCREEN; 26 | 27 | /** 28 | * @return 是否是摄像头 29 | */ 30 | public boolean isCamera() { 31 | return this == BACK || this == FRONT; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/com/acgist/taoyao/media/client/CloseableClient.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.media.client; 2 | 3 | import android.os.Handler; 4 | 5 | import com.acgist.taoyao.media.MediaManager; 6 | import com.acgist.taoyao.media.signal.ITaoyao; 7 | 8 | import java.io.Closeable; 9 | 10 | /** 11 | * 需要关闭终端 12 | * 13 | * @author acgist 14 | */ 15 | public abstract class CloseableClient implements Closeable { 16 | 17 | /** 18 | * 是否加载 19 | */ 20 | protected volatile boolean init; 21 | /** 22 | * 是否关闭 23 | */ 24 | protected volatile boolean close; 25 | /** 26 | * 信令通道 27 | */ 28 | protected final ITaoyao taoyao; 29 | /** 30 | * MainHandler 31 | */ 32 | protected final Handler mainHandler; 33 | /** 34 | * 媒体服务 35 | */ 36 | protected final MediaManager mediaManager; 37 | 38 | /** 39 | * @param taoyao 信令 40 | * @param mainHandler MainHandler 41 | */ 42 | public CloseableClient(ITaoyao taoyao, Handler mainHandler) { 43 | this.init = false; 44 | this.close = false; 45 | this.taoyao = taoyao; 46 | this.mainHandler = mainHandler; 47 | this.mediaManager = MediaManager.getInstance(); 48 | } 49 | 50 | /** 51 | * 加载 52 | */ 53 | protected void init() { 54 | this.init = true; 55 | } 56 | 57 | 58 | @Override 59 | public void close() { 60 | this.close = true; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/com/acgist/taoyao/media/client/RoomClient.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.media.client; 2 | 3 | import android.os.Handler; 4 | 5 | import com.acgist.taoyao.media.signal.ITaoyao; 6 | 7 | /** 8 | * 房间终端 9 | * SDK + NDK + Mediasoup实现视频房间 10 | * 11 | * @author acgist 12 | */ 13 | public class RoomClient extends Client { 14 | 15 | /** 16 | * @param name 终端名称 17 | * @param clientId 终端ID 18 | * @param taoyao 信令 19 | * @param mainHandler MainHandler 20 | */ 21 | protected RoomClient(String name, String clientId, ITaoyao taoyao, Handler mainHandler) { 22 | super(name, clientId, taoyao, mainHandler); 23 | } 24 | 25 | @Override 26 | public void close() { 27 | super.close(); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/com/acgist/taoyao/media/config/Config.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.media.config; 2 | 3 | /** 4 | * 配置 5 | * 6 | * @author acgist 7 | */ 8 | public class Config { 9 | 10 | /** 11 | * 屏幕捕获消息 12 | */ 13 | public static final int WHAT_SCREEN_CAPTURE = 1000; 14 | /** 15 | * 视频录像消息 16 | */ 17 | public static final int WHAT_RECORD = 1001; 18 | /** 19 | * 新建本地音频消息 20 | */ 21 | public static final int WHAT_NEW_LOCAL_AUDIO = 2000; 22 | /** 23 | * 新建本地视频消息 24 | */ 25 | public static final int WHAT_NEW_LOCAL_VIDEO = 2001; 26 | /** 27 | * 新建远程音频消息 28 | */ 29 | public static final int WHAT_NEW_REMOTE_AUDIO = 2002; 30 | /** 31 | * 新建远程视频消息 32 | */ 33 | public static final int WHAT_NEW_REMOTE_VIDEO = 2003; 34 | /** 35 | * 移除远程音频消息 36 | */ 37 | public static final int WHAT_REMOVE_AUDIO = 2998; 38 | /** 39 | * 移除远程视频消息 40 | */ 41 | public static final int WHAT_REMOVE_VIDEO = 2999; 42 | /** 43 | * 默认声音大小 44 | */ 45 | public static final double DEFAULT_VOLUME = 10.0D; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/com/acgist/taoyao/media/config/WebrtcStunProperties.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.media.config; 2 | 3 | /** 4 | * WebRTC STUN配置 5 | * 6 | * 注意:完全拷贝信令模块`WebrtcStunProperties`代码 7 | * 8 | * @author acgist 9 | */ 10 | public class WebrtcStunProperties { 11 | 12 | /** 13 | * 主机 14 | */ 15 | protected String host; 16 | /** 17 | * 端口 18 | */ 19 | protected Integer port; 20 | 21 | public String getHost() { 22 | return host; 23 | } 24 | 25 | public void setHost(String host) { 26 | this.host = host; 27 | } 28 | 29 | public Integer getPort() { 30 | return port; 31 | } 32 | 33 | public void setPort(Integer port) { 34 | this.port = port; 35 | } 36 | 37 | public String getAddress() { 38 | return "stun:" + this.host + ":" + this.port; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/com/acgist/taoyao/media/config/WebrtcTurnProperties.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.media.config; 2 | 3 | /** 4 | * WebRTC TURN配置 5 | * 6 | * 注意:完全拷贝信令模块`WebrtcTurnProperties`代码 7 | * 8 | * @author acgist 9 | */ 10 | public class WebrtcTurnProperties extends WebrtcStunProperties { 11 | 12 | /** 13 | * 帐号 14 | */ 15 | private String username; 16 | /** 17 | * 密码 18 | */ 19 | private String password; 20 | 21 | public String getUsername() { 22 | return username; 23 | } 24 | 25 | public void setUsername(String username) { 26 | this.username = username; 27 | } 28 | 29 | public String getPassword() { 30 | return password; 31 | } 32 | 33 | public void setPassword(String password) { 34 | this.password = password; 35 | } 36 | 37 | @Override 38 | public String getAddress() { 39 | return "turn:" + this.host + ":" + this.port; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/com/acgist/taoyao/media/signal/ITaoyaoListener.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.media.signal; 2 | 3 | import com.acgist.taoyao.boot.model.Message; 4 | 5 | /** 6 | * 信令监听 7 | * 8 | * @author acgist 9 | */ 10 | public interface ITaoyaoListener { 11 | 12 | /** 13 | * 前置信令处理 14 | * 15 | * @param message 信令消息 16 | * 17 | * @return 是否完成 18 | */ 19 | default boolean preOnMessage(Message message) { 20 | return false; 21 | } 22 | 23 | /** 24 | * 后置信令处理 25 | * 26 | * @param message 信令消息 27 | */ 28 | default void postOnMessage(Message message) { 29 | } 30 | 31 | /** 32 | * 信令正在连接 33 | */ 34 | default void onConnect() { 35 | } 36 | 37 | /** 38 | * 信令连接成功 39 | */ 40 | default void onConnected() { 41 | } 42 | 43 | /** 44 | * 信令断开连接 45 | */ 46 | default void onDisconnect() { 47 | } 48 | 49 | /** 50 | * 信令异常 51 | * 52 | * @param throwable 异常 53 | */ 54 | default void onError(Throwable throwable) { 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/com/acgist/taoyao/media/video/AiProcesser.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.media.video; 2 | 3 | import org.webrtc.VideoFrame; 4 | 5 | /** 6 | * AI识别处理器 7 | * 8 | * 建议不要每帧识别,如果没有识别出来结果可以复用识别结果。 9 | * 10 | * @author acgist 11 | */ 12 | public class AiProcesser extends VideoProcesser { 13 | 14 | public AiProcesser() { 15 | super("AI识别处理器"); 16 | } 17 | 18 | @Override 19 | protected void doProcess(VideoFrame.I420Buffer i420Buffer) { 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/com/acgist/taoyao/media/video/VideoProcesser.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.media.video; 2 | 3 | import android.util.Log; 4 | 5 | import org.webrtc.VideoFrame; 6 | 7 | import java.io.Closeable; 8 | 9 | /** 10 | * 视频处理器 11 | * 12 | * @author acgist 13 | */ 14 | public abstract class VideoProcesser implements Closeable { 15 | 16 | /** 17 | * 处理器名称 18 | */ 19 | protected final String name; 20 | /** 21 | * 下一个视频处理器 22 | */ 23 | protected VideoProcesser next; 24 | 25 | public VideoProcesser(String name) { 26 | this.name = name; 27 | Log.i(WatermarkProcesser.class.getSimpleName(), "加载视频处理器" + name); 28 | } 29 | 30 | /** 31 | * 处理视频帧 32 | * 33 | * @param i420Buffer 视频帧 34 | */ 35 | public void process(VideoFrame.I420Buffer i420Buffer) { 36 | this.doProcess(i420Buffer); 37 | if(this.next == null) { 38 | // 忽略 39 | } else { 40 | this.next.process(i420Buffer); 41 | } 42 | } 43 | 44 | /** 45 | * 处理视频帧 46 | * 47 | * @param i420Buffer 视频帧 48 | */ 49 | protected abstract void doProcess(VideoFrame.I420Buffer i420Buffer); 50 | 51 | /** 52 | * 关闭处理器 53 | */ 54 | public void close() { 55 | Log.i(VideoProcesser.class.getSimpleName(), "关闭视频处理器:" + this.name); 56 | if(this.next == null) { 57 | // 忽略 58 | } else { 59 | this.next.close(); 60 | } 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/AddIceObserver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2021 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Interface to handle completion of addIceCandidate */ 14 | public interface AddIceObserver { 15 | /** Called when ICE candidate added successfully.*/ 16 | @CalledByNative public void onAddSuccess(); 17 | 18 | /** Called when ICE candidate addition failed.*/ 19 | @CalledByNative public void onAddFailure(String error); 20 | } 21 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/AudioDecoderFactoryFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Implementations of this interface can create a native {@code webrtc::AudioDecoderFactory}. 15 | */ 16 | public interface AudioDecoderFactoryFactory { 17 | /** 18 | * Returns a pointer to a {@code webrtc::AudioDecoderFactory}. The caller takes ownership. 19 | */ 20 | long createNativeAudioDecoderFactory(); 21 | } 22 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/AudioEncoderFactoryFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Implementations of this interface can create a native {@code webrtc::AudioEncoderFactory}. 15 | */ 16 | public interface AudioEncoderFactoryFactory { 17 | /** 18 | * Returns a pointer to a {@code webrtc::AudioEncoderFactory}. The caller takes ownership. 19 | */ 20 | long createNativeAudioEncoderFactory(); 21 | } 22 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/AudioProcessingFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Factory for creating webrtc::AudioProcessing instances. */ 14 | public interface AudioProcessingFactory { 15 | /** 16 | * Dynamically allocates a webrtc::AudioProcessing instance and returns a pointer to it. 17 | * The caller takes ownership of the object. 18 | */ 19 | public long createNative(); 20 | } 21 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/AudioSource.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Java wrapper for a C++ AudioSourceInterface. Used as the source for one or 15 | * more {@code AudioTrack} objects. 16 | */ 17 | public class AudioSource extends MediaSource { 18 | public AudioSource(long nativeSource) { 19 | super(nativeSource); 20 | } 21 | 22 | /** Returns a pointer to webrtc::AudioSourceInterface. */ 23 | long getNativeAudioSource() { 24 | return getNativeMediaSource(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/AudioTrack.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Java wrapper for a C++ AudioTrackInterface */ 14 | public class AudioTrack extends MediaStreamTrack { 15 | public AudioTrack(long nativeTrack) { 16 | super(nativeTrack); 17 | } 18 | 19 | /** Sets the volume for the underlying MediaSource. Volume is a gain value in the range 20 | * 0 to 10. 21 | */ 22 | public void setVolume(double volume) { 23 | nativeSetVolume(getNativeAudioTrack(), volume); 24 | } 25 | 26 | /** Returns a pointer to webrtc::AudioTrackInterface. */ 27 | long getNativeAudioTrack() { 28 | return getNativeMediaStreamTrack(); 29 | } 30 | 31 | private static native void nativeSetVolume(long track, double volume); 32 | } 33 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/BaseBitrateAdjuster.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** BitrateAdjuster that tracks bitrate and framerate but does not adjust them. */ 14 | class BaseBitrateAdjuster implements BitrateAdjuster { 15 | protected int targetBitrateBps; 16 | protected int targetFps; 17 | 18 | @Override 19 | public void setTargets(int targetBitrateBps, int targetFps) { 20 | this.targetBitrateBps = targetBitrateBps; 21 | this.targetFps = targetFps; 22 | } 23 | 24 | @Override 25 | public void reportEncodedFrame(int size) { 26 | // No op. 27 | } 28 | 29 | @Override 30 | public int getAdjustedBitrateBps() { 31 | return targetBitrateBps; 32 | } 33 | 34 | @Override 35 | public int getCodecConfigFramerate() { 36 | return targetFps; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/BitrateAdjuster.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Object that adjusts the bitrate of a hardware codec. */ 14 | interface BitrateAdjuster { 15 | /** 16 | * Sets the target bitrate in bits per second and framerate in frames per second. 17 | */ 18 | void setTargets(int targetBitrateBps, int targetFps); 19 | 20 | /** 21 | * Should be used to report the size of an encoded frame to the bitrate adjuster. Use 22 | * getAdjustedBitrateBps to get the updated bitrate after calling this method. 23 | */ 24 | void reportEncodedFrame(int size); 25 | 26 | /** Gets the current bitrate. */ 27 | int getAdjustedBitrateBps(); 28 | 29 | /** Gets the framerate for initial codec configuration. */ 30 | int getCodecConfigFramerate(); 31 | } 32 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/BuiltinAudioDecoderFactoryFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Creates a native {@code webrtc::AudioDecoderFactory} with the builtin audio decoders. 15 | */ 16 | public class BuiltinAudioDecoderFactoryFactory implements AudioDecoderFactoryFactory { 17 | @Override 18 | public long createNativeAudioDecoderFactory() { 19 | return nativeCreateBuiltinAudioDecoderFactory(); 20 | } 21 | 22 | private static native long nativeCreateBuiltinAudioDecoderFactory(); 23 | } 24 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/BuiltinAudioEncoderFactoryFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * This class creates a native {@code webrtc::AudioEncoderFactory} with the builtin audio encoders. 15 | */ 16 | public class BuiltinAudioEncoderFactoryFactory implements AudioEncoderFactoryFactory { 17 | @Override 18 | public long createNativeAudioEncoderFactory() { 19 | return nativeCreateBuiltinAudioEncoderFactory(); 20 | } 21 | 22 | private static native long nativeCreateBuiltinAudioEncoderFactory(); 23 | } 24 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/CalledByNative.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import java.lang.annotation.ElementType; 14 | import java.lang.annotation.Retention; 15 | import java.lang.annotation.RetentionPolicy; 16 | import java.lang.annotation.Target; 17 | 18 | /** 19 | * @CalledByNative is used by the JNI generator to create the necessary JNI 20 | * bindings and expose this method to native code. 21 | */ 22 | @Target({ElementType.CONSTRUCTOR, ElementType.METHOD}) 23 | @Retention(RetentionPolicy.CLASS) 24 | public @interface CalledByNative { 25 | /* 26 | * If present, tells which inner class the method belongs to. 27 | */ 28 | public String value() default ""; 29 | } 30 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/CalledByNativeUnchecked.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import java.lang.annotation.ElementType; 14 | import java.lang.annotation.Retention; 15 | import java.lang.annotation.RetentionPolicy; 16 | import java.lang.annotation.Target; 17 | 18 | /** 19 | * @CalledByNativeUnchecked is used to generate JNI bindings that do not check for exceptions. 20 | * It only makes sense to use this annotation on methods that declare a throws... spec. 21 | * However, note that the exception received native side maybe an 'unchecked' (RuntimeExpception) 22 | * such as NullPointerException, so the native code should differentiate these cases. 23 | * Usage of this should be very rare; where possible handle exceptions in the Java side and use a 24 | * return value to indicate success / failure. 25 | */ 26 | @Target(ElementType.METHOD) 27 | @Retention(RetentionPolicy.CLASS) 28 | public @interface CalledByNativeUnchecked { 29 | /* 30 | * If present, tells which inner class the method belongs to. 31 | */ 32 | public String value() default ""; 33 | } 34 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/Camera1Capturer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import android.content.Context; 14 | 15 | public class Camera1Capturer extends CameraCapturer { 16 | private final boolean captureToTexture; 17 | 18 | public Camera1Capturer( 19 | String cameraName, CameraEventsHandler eventsHandler, boolean captureToTexture) { 20 | super(cameraName, eventsHandler, new Camera1Enumerator(captureToTexture)); 21 | 22 | this.captureToTexture = captureToTexture; 23 | } 24 | 25 | @Override 26 | protected void createCameraSession(CameraSession.CreateSessionCallback createSessionCallback, 27 | CameraSession.Events events, Context applicationContext, 28 | SurfaceTextureHelper surfaceTextureHelper, String cameraName, int width, int height, 29 | int framerate) { 30 | Camera1Session.create(createSessionCallback, events, captureToTexture, applicationContext, 31 | surfaceTextureHelper, Camera1Enumerator.getCameraIndex(cameraName), width, height, 32 | framerate); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/CameraEnumerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import org.webrtc.CameraEnumerationAndroid.CaptureFormat; 14 | 15 | import java.util.List; 16 | 17 | public interface CameraEnumerator { 18 | public String[] getDeviceNames(); 19 | public boolean isFrontFacing(String deviceName); 20 | public boolean isBackFacing(String deviceName); 21 | public List getSupportedFormats(String deviceName); 22 | 23 | public CameraVideoCapturer createCapturer( 24 | String deviceName, CameraVideoCapturer.CameraEventsHandler eventsHandler); 25 | } 26 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/CapturerObserver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Interface for observering a capturer. Passed to {@link VideoCapturer#initialize}. Provided by 15 | * {@link VideoSource#getCapturerObserver}. 16 | * 17 | * All callbacks must be executed on a single thread. 18 | */ 19 | public interface CapturerObserver { 20 | /** Notify if the capturer have been started successfully or not. */ 21 | void onCapturerStarted(boolean success); 22 | /** Notify that the capturer has been stopped. */ 23 | void onCapturerStopped(); 24 | 25 | /** Delivers a captured frame. */ 26 | void onFrameCaptured(VideoFrame frame); 27 | } 28 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/EglBase10.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import javax.microedition.khronos.egl.EGLContext; 14 | 15 | /** EGL 1.0 implementation of EglBase. */ 16 | public interface EglBase10 extends EglBase { 17 | interface Context extends EglBase.Context { 18 | EGLContext getRawContext(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/EglBase14.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import android.opengl.EGLContext; 14 | 15 | /** EGL 1.4 implementation of EglBase. */ 16 | public interface EglBase14 extends EglBase { 17 | interface Context extends EglBase.Context { 18 | EGLContext getRawContext(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/Empty.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Empty class for use in libjingle_peerconnection_java because all targets require at least one 15 | * Java file. 16 | */ 17 | class Empty {} 18 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/FecControllerFactoryFactoryInterface.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Factory for creating webrtc::FecControllerFactory instances. 15 | */ 16 | public interface FecControllerFactoryFactoryInterface { 17 | /** 18 | * Dynamically allocates a webrtc::FecControllerFactory instance and returns a pointer to it. 19 | * The caller takes ownership of the object. 20 | */ 21 | public long createNative(); 22 | } 23 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/FrameDecryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * The FrameDecryptor interface allows Java API users to provide a 15 | * pointer to their native implementation of the FrameDecryptorInterface. 16 | * FrameDecryptors are extremely performance sensitive as they must process all 17 | * incoming video and audio frames. Due to this reason they should always be 18 | * backed by a native implementation 19 | * @note Not ready for production use. 20 | */ 21 | public interface FrameDecryptor { 22 | /** 23 | * @return A FrameDecryptorInterface pointer. 24 | */ 25 | long getNativeFrameDecryptor(); 26 | } 27 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/FrameEncryptor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * The FrameEncryptor interface allows Java API users to provide a pointer to 15 | * their native implementation of the FrameEncryptorInterface. 16 | * FrameEncyptors are extremely performance sensitive as they must process all 17 | * outgoing video and audio frames. Due to this reason they should always be 18 | * backed by a native implementation. 19 | * @note Not ready for production use. 20 | */ 21 | public interface FrameEncryptor { 22 | /** 23 | * @return A FrameEncryptorInterface pointer. 24 | */ 25 | long getNativeFrameEncryptor(); 26 | } 27 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/FramerateBitrateAdjuster.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * BitrateAdjuster that adjusts the bitrate to compensate for changes in the framerate. Used with 15 | * hardware codecs that assume the framerate never changes. 16 | */ 17 | class FramerateBitrateAdjuster extends BaseBitrateAdjuster { 18 | private static final int INITIAL_FPS = 30; 19 | 20 | @Override 21 | public void setTargets(int targetBitrateBps, int targetFps) { 22 | if (this.targetFps == 0) { 23 | // Framerate-based bitrate adjustment always initializes to the same framerate. 24 | targetFps = INITIAL_FPS; 25 | } 26 | super.setTargets(targetBitrateBps, targetFps); 27 | 28 | this.targetBitrateBps = this.targetBitrateBps * INITIAL_FPS / this.targetFps; 29 | } 30 | 31 | @Override 32 | public int getCodecConfigFramerate() { 33 | return INITIAL_FPS; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/GlRectDrawer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Simplest possible GL shader that just draws frames as opaque quads. */ 14 | public class GlRectDrawer extends GlGenericDrawer { 15 | private static final String FRAGMENT_SHADER = "void main() {\n" 16 | + " gl_FragColor = sample(tc);\n" 17 | + "}\n"; 18 | 19 | private static class ShaderCallbacks implements GlGenericDrawer.ShaderCallbacks { 20 | @Override 21 | public void onNewShader(GlShader shader) {} 22 | 23 | @Override 24 | public void onPrepareShader(GlShader shader, float[] texMatrix, int frameWidth, int frameHeight, 25 | int viewportWidth, int viewportHeight) {} 26 | } 27 | 28 | public GlRectDrawer() { 29 | super(FRAGMENT_SHADER, new ShaderCallbacks()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/JNILogging.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC Project Authors. All rights reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import org.webrtc.Logging.Severity; 14 | 15 | class JNILogging { 16 | private final Loggable loggable; 17 | 18 | public JNILogging(Loggable loggable) { 19 | this.loggable = loggable; 20 | } 21 | 22 | @CalledByNative 23 | public void logToInjectable(String message, Integer severity, String tag) { 24 | loggable.onLogMessage(message, Severity.values()[severity], tag); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/JniCommon.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import java.nio.ByteBuffer; 14 | 15 | /** Class with static JNI helper functions that are used in many places. */ 16 | public class JniCommon { 17 | /** Functions to increment/decrement an rtc::RefCountInterface pointer. */ 18 | public static native void nativeAddRef(long refCountedPointer); 19 | public static native void nativeReleaseRef(long refCountedPointer); 20 | 21 | public static native ByteBuffer nativeAllocateByteBuffer(int size); 22 | public static native void nativeFreeByteBuffer(ByteBuffer buffer); 23 | } 24 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/LibaomAv1Decoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | public class LibaomAv1Decoder extends WrappedNativeVideoDecoder { 14 | @Override 15 | public long createNativeVideoDecoder() { 16 | return nativeCreateDecoder(); 17 | } 18 | 19 | static native long nativeCreateDecoder(); 20 | 21 | static native boolean nativeIsSupported(); 22 | } 23 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/LibaomAv1Encoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | public class LibaomAv1Encoder extends WrappedNativeVideoEncoder { 14 | @Override 15 | public long createNativeVideoEncoder() { 16 | return nativeCreateEncoder(); 17 | } 18 | 19 | static native long nativeCreateEncoder(); 20 | 21 | @Override 22 | public boolean isHardwareEncoder() { 23 | return false; 24 | } 25 | 26 | static native boolean nativeIsSupported(); 27 | } 28 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/LibvpxVp8Decoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | public class LibvpxVp8Decoder extends WrappedNativeVideoDecoder { 14 | @Override 15 | public long createNativeVideoDecoder() { 16 | return nativeCreateDecoder(); 17 | } 18 | 19 | static native long nativeCreateDecoder(); 20 | } 21 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/LibvpxVp8Encoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | public class LibvpxVp8Encoder extends WrappedNativeVideoEncoder { 14 | @Override 15 | public long createNativeVideoEncoder() { 16 | return nativeCreateEncoder(); 17 | } 18 | 19 | static native long nativeCreateEncoder(); 20 | 21 | @Override 22 | public boolean isHardwareEncoder() { 23 | return false; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/LibvpxVp9Decoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | public class LibvpxVp9Decoder extends WrappedNativeVideoDecoder { 14 | @Override 15 | public long createNativeVideoDecoder() { 16 | return nativeCreateDecoder(); 17 | } 18 | 19 | static native long nativeCreateDecoder(); 20 | 21 | static native boolean nativeIsSupported(); 22 | } 23 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/LibvpxVp9Encoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | public class LibvpxVp9Encoder extends WrappedNativeVideoEncoder { 14 | @Override 15 | public long createNativeVideoEncoder() { 16 | return nativeCreateEncoder(); 17 | } 18 | 19 | static native long nativeCreateEncoder(); 20 | 21 | @Override 22 | public boolean isHardwareEncoder() { 23 | return false; 24 | } 25 | 26 | static native boolean nativeIsSupported(); 27 | } 28 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/Loggable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import org.webrtc.Logging.Severity; 14 | 15 | /** 16 | * Java interface for WebRTC logging. The default implementation uses webrtc.Logging. 17 | * 18 | * When injected, the Loggable will receive logging from both Java and native. 19 | */ 20 | public interface Loggable { 21 | public void onLogMessage(String message, Severity severity, String tag); 22 | } 23 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/MediaCodecWrapperFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import java.io.IOException; 14 | 15 | interface MediaCodecWrapperFactory { 16 | /** 17 | * Creates a new {@link MediaCodecWrapper} by codec name. 18 | * 19 | *

For additional information see {@link android.media.MediaCodec#createByCodecName}. 20 | */ 21 | MediaCodecWrapper createByCodecName(String name) throws IOException; 22 | } 23 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/NativeLibraryLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Interface for loading native libraries. A custom loader can be passed to 15 | * PeerConnectionFactory.initialize. 16 | */ 17 | public interface NativeLibraryLoader { 18 | /** 19 | * Loads a native library with the given name. 20 | * 21 | * @return True on success 22 | */ 23 | boolean load(String name); 24 | } 25 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/NativePeerConnectionFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Factory for creating webrtc::jni::OwnedPeerConnection instances. */ 14 | public interface NativePeerConnectionFactory { 15 | /** 16 | * Create a new webrtc::jni::OwnedPeerConnection instance and returns a pointer to it. 17 | * The caller takes ownership of the object. 18 | */ 19 | long createNativePeerConnection(); 20 | } 21 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/NetEqFactoryFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Implementations of this interface can create a native {@code webrtc::NetEqFactory}. 15 | */ 16 | public interface NetEqFactoryFactory { 17 | /** 18 | * Returns a pointer to a {@code webrtc::NetEqFactory}. The caller takes ownership. 19 | */ 20 | long createNativeNetEqFactory(); 21 | } 22 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/NetworkChangeDetectorFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2020 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import android.content.Context; 14 | 15 | public interface NetworkChangeDetectorFactory { 16 | public NetworkChangeDetector create(NetworkChangeDetector.Observer observer, Context context); 17 | } 18 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/NetworkControllerFactoryFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Factory for creating webrtc::NetworkControllerFactory instances. */ 14 | public interface NetworkControllerFactoryFactory { 15 | /** 16 | * Dynamically allocates a webrtc::NetworkControllerFactory instance and returns a pointer to 17 | * it. The caller takes ownership of the object. 18 | */ 19 | public long createNativeNetworkControllerFactory(); 20 | } 21 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/NetworkPreference.java: -------------------------------------------------------------------------------- 1 | 2 | // Copyright 2023 The Chromium Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style license that can be 4 | // found in the LICENSE file. 5 | 6 | // This file is autogenerated by 7 | // java_cpp_enum.py 8 | // From 9 | // ../../../rtc_base/network_monitor.h 10 | 11 | package org.webrtc; 12 | 13 | import androidx.annotation.IntDef; 14 | 15 | import java.lang.annotation.Retention; 16 | import java.lang.annotation.RetentionPolicy; 17 | 18 | @IntDef({ 19 | NetworkPreference.NEUTRAL, NetworkPreference.NOT_PREFERRED 20 | }) 21 | @Retention(RetentionPolicy.SOURCE) 22 | public @interface NetworkPreference { 23 | int NEUTRAL = 0; 24 | int NOT_PREFERRED = -1; 25 | } 26 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/NetworkStatePredictorFactoryFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Factory for creating webrtc::NetworkStatePredictorFactory instances. */ 14 | public interface NetworkStatePredictorFactoryFactory { 15 | /** 16 | * Dynamically allocates a webrtc::NetworkStatePredictorFactory instance and returns a pointer to 17 | * it. The caller takes ownership of the object. 18 | */ 19 | public long createNativeNetworkStatePredictorFactory(); 20 | } 21 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/Priority.java: -------------------------------------------------------------------------------- 1 | 2 | // Copyright 2023 The Chromium Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style license that can be 4 | // found in the LICENSE file. 5 | 6 | // This file is autogenerated by 7 | // java_cpp_enum.py 8 | // From 9 | // ../../../api/priority.h 10 | 11 | package org.webrtc; 12 | 13 | import androidx.annotation.IntDef; 14 | 15 | import java.lang.annotation.Retention; 16 | import java.lang.annotation.RetentionPolicy; 17 | 18 | @IntDef({ 19 | Priority.VERY_LOW, Priority.LOW, Priority.MEDIUM, Priority.HIGH 20 | }) 21 | @Retention(RetentionPolicy.SOURCE) 22 | public @interface Priority { 23 | int VERY_LOW = 0; 24 | int LOW = 1; 25 | int MEDIUM = 2; 26 | int HIGH = 3; 27 | } 28 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/RTCStatsCollectorCallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Interface for receiving stats reports (see webrtc::RTCStatsCollectorCallback). */ 14 | public interface RTCStatsCollectorCallback { 15 | /** Called when the stats report is ready. */ 16 | @CalledByNative public void onStatsDelivered(RTCStatsReport report); 17 | } 18 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/RefCounted.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Interface for ref counted objects in WebRTC. These objects have significant resources that need 15 | * to be freed when they are no longer in use. Each objects starts with ref count of one when 16 | * created. If a reference is passed as a parameter to a method, the caller has ownesrship of the 17 | * object by default - calling release is not necessary unless retain is called. 18 | */ 19 | public interface RefCounted { 20 | /** Increases ref count by one. */ 21 | @CalledByNative void retain(); 22 | 23 | /** 24 | * Decreases ref count by one. When the ref count reaches zero, resources related to the object 25 | * will be freed. 26 | */ 27 | @CalledByNative void release(); 28 | } 29 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/SSLCertificateVerifier.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2018 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * The SSLCertificateVerifier interface allows API users to provide custom 15 | * logic to verify certificates. 16 | */ 17 | public interface SSLCertificateVerifier { 18 | /** 19 | * Implementations of verify allow applications to provide custom logic for 20 | * verifying certificates. This is not required by default and should be used 21 | * with care. 22 | * 23 | * @param certificate A byte array containing a DER encoded X509 certificate. 24 | * @return True if the certificate is verified and trusted else false. 25 | */ 26 | @CalledByNative boolean verify(byte[] certificate); 27 | } 28 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/SdpObserver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Interface for observing SDP-related events. */ 14 | public interface SdpObserver { 15 | /** Called on success of Create{Offer,Answer}(). */ 16 | @CalledByNative void onCreateSuccess(SessionDescription sdp); 17 | 18 | /** Called on success of Set{Local,Remote}Description(). */ 19 | @CalledByNative void onSetSuccess(); 20 | 21 | /** Called on error of Create{Offer,Answer}(). */ 22 | @CalledByNative void onCreateFailure(String error); 23 | 24 | /** Called on error of Set{Local,Remote}Description(). */ 25 | @CalledByNative void onSetFailure(String error); 26 | } 27 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/Size.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2016 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Class for representing size of an object. Very similar to android.util.Size but available on all 15 | * devices. 16 | */ 17 | public class Size { 18 | public int width; 19 | public int height; 20 | 21 | public Size(int width, int height) { 22 | this.width = width; 23 | this.height = height; 24 | } 25 | 26 | @Override 27 | public String toString() { 28 | return width + "x" + height; 29 | } 30 | 31 | @Override 32 | public boolean equals(Object other) { 33 | if (!(other instanceof Size)) { 34 | return false; 35 | } 36 | final Size otherSize = (Size) other; 37 | return width == otherSize.width && height == otherSize.height; 38 | } 39 | 40 | @Override 41 | public int hashCode() { 42 | // Use prime close to 2^16 to avoid collisions for normal values less than 2^16. 43 | return 1 + 65537 * width + height; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/StatsObserver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2013 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Interface for observing Stats reports (see webrtc::StatsObservers). */ 14 | public interface StatsObserver { 15 | /** Called when the reports are ready.*/ 16 | @CalledByNative public void onComplete(StatsReport[] reports); 17 | } 18 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/TurnCustomizer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Java wrapper for a C++ TurnCustomizer. */ 14 | public class TurnCustomizer { 15 | private long nativeTurnCustomizer; 16 | 17 | public TurnCustomizer(long nativeTurnCustomizer) { 18 | this.nativeTurnCustomizer = nativeTurnCustomizer; 19 | } 20 | 21 | public void dispose() { 22 | checkTurnCustomizerExists(); 23 | nativeFreeTurnCustomizer(nativeTurnCustomizer); 24 | nativeTurnCustomizer = 0; 25 | } 26 | 27 | private static native void nativeFreeTurnCustomizer(long turnCustomizer); 28 | 29 | /** Return a pointer to webrtc::TurnCustomizer. */ 30 | @CalledByNative 31 | long getNativeTurnCustomizer() { 32 | checkTurnCustomizerExists(); 33 | return nativeTurnCustomizer; 34 | } 35 | 36 | private void checkTurnCustomizerExists() { 37 | if (nativeTurnCustomizer == 0) { 38 | throw new IllegalStateException("TurnCustomizer has been disposed."); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/VideoCodecMimeType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** Enumeration of supported video codec types. */ 14 | enum VideoCodecMimeType { 15 | VP8("video/x-vnd.on2.vp8"), 16 | VP9("video/x-vnd.on2.vp9"), 17 | H264("video/avc"), 18 | AV1("video/av01"); 19 | 20 | private final String mimeType; 21 | 22 | private VideoCodecMimeType(String mimeType) { 23 | this.mimeType = mimeType; 24 | } 25 | 26 | String mimeType() { 27 | return mimeType; 28 | } 29 | 30 | static VideoCodecMimeType fromSdpCodecName(String codecName) { 31 | return codecName.equals("AV1X") ? AV1 : valueOf(codecName); 32 | } 33 | 34 | String toSdpCodecName() { 35 | return this == AV1 ? "AV1X" : name(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/VideoCodecStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Status codes reported by video encoding/decoding components. This should be kept in sync with 15 | * video_error_codes.h. 16 | */ 17 | public enum VideoCodecStatus { 18 | REQUEST_SLI(2), 19 | NO_OUTPUT(1), 20 | OK(0), 21 | ERROR(-1), 22 | LEVEL_EXCEEDED(-2), 23 | MEMORY(-3), 24 | ERR_PARAMETER(-4), 25 | ERR_SIZE(-5), 26 | TIMEOUT(-6), 27 | UNINITIALIZED(-7), 28 | ERR_REQUEST_SLI(-12), 29 | FALLBACK_SOFTWARE(-13), 30 | TARGET_BITRATE_OVERSHOOT(-14); 31 | 32 | private final int number; 33 | 34 | private VideoCodecStatus(int number) { 35 | this.number = number; 36 | } 37 | 38 | @CalledByNative 39 | public int getNumber() { 40 | return number; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/VideoDecoderFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | import androidx.annotation.Nullable; 14 | 15 | /** Factory for creating VideoDecoders. */ 16 | public interface VideoDecoderFactory { 17 | /** 18 | * Creates a VideoDecoder for the given codec. Supports the same codecs supported by 19 | * VideoEncoderFactory. 20 | */ 21 | @Nullable @CalledByNative VideoDecoder createDecoder(VideoCodecInfo info); 22 | 23 | /** 24 | * Enumerates the list of supported video codecs. 25 | */ 26 | @CalledByNative 27 | default VideoCodecInfo[] getSupportedCodecs() { 28 | return new VideoCodecInfo[0]; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/VideoDecoderFallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * A combined video decoder that falls back on a secondary decoder if the primary decoder fails. 15 | */ 16 | public class VideoDecoderFallback extends WrappedNativeVideoDecoder { 17 | private final VideoDecoder fallback; 18 | private final VideoDecoder primary; 19 | 20 | public VideoDecoderFallback(VideoDecoder fallback, VideoDecoder primary) { 21 | this.fallback = fallback; 22 | this.primary = primary; 23 | } 24 | 25 | @Override 26 | public long createNativeVideoDecoder() { 27 | return nativeCreateDecoder(fallback, primary); 28 | } 29 | 30 | private static native long nativeCreateDecoder(VideoDecoder fallback, VideoDecoder primary); 31 | } 32 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/VideoDecoderWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * This class contains the Java glue code for JNI generation of VideoDecoder. 15 | */ 16 | class VideoDecoderWrapper { 17 | @CalledByNative 18 | static VideoDecoder.Callback createDecoderCallback(final long nativeDecoder) { 19 | return (VideoFrame frame, Integer decodeTimeMs, 20 | Integer qp) -> nativeOnDecodedFrame(nativeDecoder, frame, decodeTimeMs, qp); 21 | } 22 | 23 | private static native void nativeOnDecodedFrame( 24 | long nativeVideoDecoderWrapper, VideoFrame frame, Integer decodeTimeMs, Integer qp); 25 | } 26 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/VideoEncoderFallback.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * A combined video encoder that falls back on a secondary encoder if the primary encoder fails. 15 | */ 16 | public class VideoEncoderFallback extends WrappedNativeVideoEncoder { 17 | private final VideoEncoder fallback; 18 | private final VideoEncoder primary; 19 | 20 | public VideoEncoderFallback(VideoEncoder fallback, VideoEncoder primary) { 21 | this.fallback = fallback; 22 | this.primary = primary; 23 | } 24 | 25 | @Override 26 | public long createNativeVideoEncoder() { 27 | return nativeCreateEncoder(fallback, primary); 28 | } 29 | 30 | @Override 31 | public boolean isHardwareEncoder() { 32 | return primary.isHardwareEncoder(); 33 | } 34 | 35 | private static native long nativeCreateEncoder(VideoEncoder fallback, VideoEncoder primary); 36 | } 37 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/VideoFrameBufferType.java: -------------------------------------------------------------------------------- 1 | 2 | // Copyright 2023 The Chromium Authors. All rights reserved. 3 | // Use of this source code is governed by a BSD-style license that can be 4 | // found in the LICENSE file. 5 | 6 | // This file is autogenerated by 7 | // java_cpp_enum.py 8 | // From 9 | // ../../../api/video/video_frame_buffer.h 10 | 11 | package org.webrtc; 12 | 13 | import androidx.annotation.IntDef; 14 | 15 | import java.lang.annotation.Retention; 16 | import java.lang.annotation.RetentionPolicy; 17 | 18 | @IntDef({ 19 | VideoFrameBufferType.NATIVE, VideoFrameBufferType.I420, VideoFrameBufferType.I420A, 20 | VideoFrameBufferType.I444, VideoFrameBufferType.I010, VideoFrameBufferType.NV12 21 | }) 22 | @Retention(RetentionPolicy.SOURCE) 23 | public @interface VideoFrameBufferType { 24 | int NATIVE = 0; 25 | int I420 = 1; 26 | int I420A = 2; 27 | int I444 = 3; 28 | int I010 = 4; 29 | int NV12 = 5; 30 | } 31 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/VideoSink.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Java version of rtc::VideoSinkInterface. 15 | */ 16 | public interface VideoSink { 17 | /** 18 | * Implementations should call frame.retain() if they need to hold a reference to the frame after 19 | * this function returns. Each call to retain() should be followed by a call to frame.release() 20 | * when the reference is no longer needed. 21 | */ 22 | @CalledByNative void onFrame(VideoFrame frame); 23 | } 24 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/WebRtcClassLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * This class provides a ClassLoader that is capable of loading WebRTC Java classes regardless of 15 | * what thread it's called from. Such a ClassLoader is needed for the few cases where the JNI 16 | * mechanism is unable to automatically determine the appropriate ClassLoader instance. 17 | */ 18 | class WebRtcClassLoader { 19 | @CalledByNative 20 | static Object getClassLoader() { 21 | Object loader = WebRtcClassLoader.class.getClassLoader(); 22 | if (loader == null) { 23 | throw new RuntimeException("Failed to get WebRTC class loader."); 24 | } 25 | return loader; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/WrappedNativeVideoDecoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc; 12 | 13 | /** 14 | * Wraps a native webrtc::VideoDecoder. 15 | */ 16 | public abstract class WrappedNativeVideoDecoder implements VideoDecoder { 17 | @Override public abstract long createNativeVideoDecoder(); 18 | 19 | @Override 20 | public final VideoCodecStatus initDecode(Settings settings, Callback decodeCallback) { 21 | throw new UnsupportedOperationException("Not implemented."); 22 | } 23 | 24 | @Override 25 | public final VideoCodecStatus release() { 26 | throw new UnsupportedOperationException("Not implemented."); 27 | } 28 | 29 | @Override 30 | public final VideoCodecStatus decode(EncodedImage frame, DecodeInfo info) { 31 | throw new UnsupportedOperationException("Not implemented."); 32 | } 33 | 34 | @Override 35 | public final String getImplementationName() { 36 | throw new UnsupportedOperationException("Not implemented."); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/media/src/main/java/org/webrtc/voiceengine/BuildInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 3 | * 4 | * Use of this source code is governed by a BSD-style license 5 | * that can be found in the LICENSE file in the root of the source 6 | * tree. An additional intellectual property rights grant can be found 7 | * in the file PATENTS. All contributing project authors may 8 | * be found in the AUTHORS file in the root of the source tree. 9 | */ 10 | 11 | package org.webrtc.voiceengine; 12 | 13 | import android.os.Build; 14 | 15 | public final class BuildInfo { 16 | public static String getDevice() { 17 | return Build.DEVICE; 18 | } 19 | 20 | public static String getDeviceModel() { 21 | return Build.MODEL; 22 | } 23 | 24 | public static String getProduct() { 25 | return Build.PRODUCT; 26 | } 27 | 28 | public static String getBrand() { 29 | return Build.BRAND; 30 | } 31 | 32 | public static String getDeviceManufacturer() { 33 | return Build.MANUFACTURER; 34 | } 35 | 36 | public static String getAndroidBuildId() { 37 | return Build.ID; 38 | } 39 | 40 | public static String getBuildType() { 41 | return Build.TYPE; 42 | } 43 | 44 | public static String getBuildRelease() { 45 | return Build.VERSION.RELEASE; 46 | } 47 | 48 | public static int getSdkVersion() { 49 | return Build.VERSION.SDK_INT; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /taoyao-client-android/taoyao/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | maven { url 'https://maven.aliyun.com/repository/google' } 4 | maven { url 'https://maven.aliyun.com/repository/public' } 5 | maven { url 'https://maven.aliyun.com/repository/central' } 6 | maven { url 'https://maven.aliyun.com/repository/jcenter' } 7 | maven { url 'https://maven.aliyun.com/repository/releases' } 8 | maven { url 'https://maven.aliyun.com/repository/gradle-plugin' } 9 | google() 10 | mavenCentral() 11 | gradlePluginPortal() 12 | } 13 | } 14 | dependencyResolutionManagement { 15 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) 16 | repositories { 17 | maven { url 'https://maven.aliyun.com/repository/google' } 18 | maven { url 'https://maven.aliyun.com/repository/public' } 19 | maven { url 'https://maven.aliyun.com/repository/central' } 20 | maven { url 'https://maven.aliyun.com/repository/jcenter' } 21 | maven { url 'https://maven.aliyun.com/repository/releases' } 22 | maven { url 'https://maven.aliyun.com/repository/gradle-plugin' } 23 | google() 24 | mavenCentral() 25 | } 26 | } 27 | rootProject.name = "taoyao" 28 | include ':boot' 29 | include ':media' 30 | include ':client' 31 | -------------------------------------------------------------------------------- /taoyao-client-media/.env: -------------------------------------------------------------------------------- 1 | # 服务名称 2 | NAME=taoyao-client-media 3 | # 终端ID 4 | CLIENT_ID=taoyao-client-media 5 | # 终端名称 6 | CLIENT_NAME=桃夭媒体服务 7 | # 信令版本 8 | SIGNAL_VERSION=1.0.0 9 | # 信令地址 10 | SIGNAL_HOST=127.0.0.1 11 | # 信令端口 12 | SIGNAL_PORT=8888 13 | # 信令帐号 14 | SIGNAL_USERNAME=taoyao 15 | # 信令密码 16 | SIGNAL_PASSWORD=taoyao 17 | # 工作线程数量(生产环境不要配置) 18 | MEDIASOUP_WORKER_SIZE=2 19 | # Mediasoup最小端口 20 | MEDIASOUP_MIN_PORT=40000 21 | # Mediasoup最大端口 22 | MEDIASOUP_MAX_PORT=49999 23 | # Mediasoup监听地址 24 | MEDIASOUP_LISTEN_IP=0.0.0.0 25 | # Mediasoup监听端口(起始端口) 26 | MEDIASOUP_LISTEN_PORT=44444 27 | # Mediasoup声明地址(不能配置环回地址) 28 | MEDIASOUP_ANNOUNCED_IP=192.168.1.100 -------------------------------------------------------------------------------- /taoyao-client-media/.env.node-a: -------------------------------------------------------------------------------- 1 | NAME=taoyao-client-media-a 2 | CLIENT_ID=taoyao-client-media-a 3 | CLIENT_NAME=桃夭媒体服务A 4 | SIGNAL_VERSION=1.0.0 5 | SIGNAL_HOST=127.0.0.1 6 | SIGNAL_PORT=8888 7 | SIGNAL_USERNAME=taoyao 8 | SIGNAL_PASSWORD=taoyao 9 | MEDIASOUP_WORKER_SIZE=2 10 | MEDIASOUP_MIN_PORT=40000 11 | MEDIASOUP_MAX_PORT=49999 12 | MEDIASOUP_LISTEN_IP=0.0.0.0 13 | MEDIASOUP_LISTEN_PORT=41111 14 | MEDIASOUP_ANNOUNCED_IP=192.168.1.110 -------------------------------------------------------------------------------- /taoyao-client-media/.env.node-b: -------------------------------------------------------------------------------- 1 | NAME=taoyao-client-media-b 2 | CLIENT_ID=taoyao-client-media-b 3 | CLIENT_NAME=桃夭媒体服务B 4 | SIGNAL_VERSION=1.0.0 5 | SIGNAL_HOST=127.0.0.1 6 | SIGNAL_PORT=8888 7 | SIGNAL_USERNAME=taoyao 8 | SIGNAL_PASSWORD=taoyao 9 | MEDIASOUP_WORKER_SIZE=2 10 | MEDIASOUP_MIN_PORT=40000 11 | MEDIASOUP_MAX_PORT=49999 12 | MEDIASOUP_LISTEN_IP=0.0.0.0 13 | MEDIASOUP_LISTEN_PORT=42222 14 | MEDIASOUP_ANNOUNCED_IP=192.168.1.110 -------------------------------------------------------------------------------- /taoyao-client-media/.env.prd: -------------------------------------------------------------------------------- 1 | NAME=taoyao-client-media 2 | CLIENT_ID=taoyao-client-media 3 | CLIENT_NAME=桃夭媒体服务 4 | SIGNAL_VERSION=1.0.0 5 | SIGNAL_HOST=127.0.0.1 6 | SIGNAL_PORT=8888 7 | SIGNAL_USERNAME=taoyao 8 | SIGNAL_PASSWORD=taoyao 9 | MEDIASOUP_MIN_PORT=40000 10 | MEDIASOUP_MAX_PORT=49999 11 | MEDIASOUP_LISTEN_IP=0.0.0.0 12 | MEDIASOUP_LISTEN_PORT=44444 13 | MEDIASOUP_ANNOUNCED_IP=192.168.1.110 -------------------------------------------------------------------------------- /taoyao-client-media/.env.work: -------------------------------------------------------------------------------- 1 | NAME=taoyao-client-media 2 | CLIENT_ID=taoyao-client-media 3 | CLIENT_NAME=桃夭媒体服务 4 | SIGNAL_VERSION=1.0.0 5 | SIGNAL_HOST=127.0.0.1 6 | SIGNAL_PORT=8888 7 | SIGNAL_USERNAME=taoyao 8 | SIGNAL_PASSWORD=taoyao 9 | MEDIASOUP_WORKER_SIZE=2 10 | MEDIASOUP_MIN_PORT=40000 11 | MEDIASOUP_MAX_PORT=49999 12 | MEDIASOUP_LISTEN_IP=0.0.0.0 13 | MEDIASOUP_LISTEN_PORT=44444 14 | MEDIASOUP_ANNOUNCED_IP=192.168.8.100 -------------------------------------------------------------------------------- /taoyao-client-media/ecosystem.config.cluster.json: -------------------------------------------------------------------------------- 1 | { 2 | "apps": [ 3 | { 4 | "cwd" : "./", 5 | "name" : "taoyao-client-media", 6 | "script" : "src/Server.js", 7 | "instances" : 2, 8 | "exec_mode" : "cluster", 9 | "out_file" : "./logs/out.log", 10 | "error_file" : "./logs/error.log", 11 | "log_date_format": "YYYY-MM-DD HH:mm:ss" 12 | } 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /taoyao-client-media/ecosystem.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "apps": [ 3 | { 4 | "cwd" : "./", 5 | "name" : "taoyao-client-media", 6 | "script" : "src/Server.js", 7 | "out_file" : "./logs/out.log", 8 | "error_file" : "./logs/error.log", 9 | "log_date_format": "YYYY-MM-DD HH:mm:ss" 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /taoyao-client-media/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "taoyao-client-media", 3 | "author" : "acgist", 4 | "version" : "1.0.0", 5 | "private" : true, 6 | "license" : "Apache-2.0", 7 | "homepage" : "https://gitee.com/acgist/taoyao", 8 | "description": "taoyao client media", 9 | "scripts": { 10 | "dev" : "node src/Server.js", 11 | "prd" : "cross-env NODE_ENV=prd node src/Server.js", 12 | "work" : "cross-env NODE_ENV=work node src/Server.js", 13 | "node-a": "cross-env NODE_ENV=node-a node src/Server.js", 14 | "node-b": "cross-env NODE_ENV=node-b node src/Server.js" 15 | }, 16 | "dependencies": { 17 | "ws" : "^8.12.0", 18 | "dotenv" : "^16.3.1", 19 | "cross-env": "^7.0.3", 20 | "mediasoup": "^3.11.10" 21 | } 22 | } -------------------------------------------------------------------------------- /taoyao-client-web/README.md: -------------------------------------------------------------------------------- 1 | # Web终端 2 | 3 | ## Web终端 4 | 5 | * [mediasoup-client源码](https://github.com/versatica/mediasoup-client) 6 | * [mediasoup-client文档](https://mediasoup.org/documentation/v3/mediasoup-client) 7 | * [mediasoup-client接口](https://mediasoup.org/documentation/v3/mediasoup-client/api) 8 | 9 | ## 终端媒体 10 | 11 | 终端页面组件需要提供`media`方法,同时挂载到终端的`proxy`属性下面。 12 | 媒体生成以后自动调用: 13 | 14 | ``` 15 | LocalClient.proxy.media(track, producer); 16 | RemoteClient.proxy.media(track, consumer); 17 | SessionClient.proxy.media(track); 18 | ``` 19 | 20 | ## 终端列表 21 | 22 | `Web`终端并未对整个终端列表以及状态进行维护,所以需要开发者自己实现。 23 | -------------------------------------------------------------------------------- /taoyao-client-web/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-web/favicon.ico -------------------------------------------------------------------------------- /taoyao-client-web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 桃夭终端 9 | 10 | 11 | 12 |

13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /taoyao-client-web/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "taoyao-client-web", 3 | "author" : "acgist", 4 | "version" : "1.0.0", 5 | "private" : true, 6 | "license" : "Apache-2.0", 7 | "homepage" : "https://gitee.com/acgist/taoyao", 8 | "description": "taoyao client web", 9 | "scripts": { 10 | "dev" : "vite", 11 | "build" : "vite build", 12 | "preview": "vite preview" 13 | }, 14 | "dependencies": { 15 | "vue" : "^3.2.44", 16 | "moment" : "^2.29.4", 17 | "element-plus" : "^2.2.32", 18 | "mediasoup-client" : "^3.6.82", 19 | "@element-plus/icons-vue": "^2.1.0" 20 | }, 21 | "devDependencies": { 22 | "vite" : "^4.0.0", 23 | "@vitejs/plugin-vue": "^4.0.0" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /taoyao-client-web/public/taoyao.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-web/public/taoyao.ttf -------------------------------------------------------------------------------- /taoyao-client-web/public/taoyao.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-client-web/public/taoyao.woff -------------------------------------------------------------------------------- /taoyao-client-web/src/assets/main.css: -------------------------------------------------------------------------------- 1 | @import "./base.css"; 2 | @import "./font.css"; 3 | 4 | #app { 5 | max-width: 1280px; 6 | margin: 0 auto; 7 | padding: 2rem; 8 | font-weight: normal; 9 | } 10 | 11 | a, 12 | .green { 13 | text-decoration: none; 14 | color: hsla(160, 100%, 37%, 1); 15 | transition: 0.4s; 16 | } 17 | 18 | @media (hover: hover) { 19 | a:hover { 20 | background-color: hsla(160, 100%, 37%, 0.2); 21 | } 22 | } 23 | 24 | @media (min-width: 1024px) { 25 | body { 26 | display: flex; 27 | place-items: center; 28 | } 29 | 30 | #app { 31 | display: grid; 32 | grid-template-columns: 1fr 1fr; 33 | padding: 0 2rem; 34 | } 35 | } -------------------------------------------------------------------------------- /taoyao-client-web/src/certs/server.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIID2TCCAsGgAwIBAgIJAMdfMbITNAhiMA0GCSqGSIb3DQEBCwUAMF4xCzAJBgNV 3 | BAYTAmNuMQswCQYDVQQIDAJnZDELMAkGA1UEBwwCZ3oxDzANBgNVBAoMBmFjZ2lz 4 | dDEPMA0GA1UECwwGYWNnaXN0MRMwEQYDVQQDDAphY2dpc3QuY29tMB4XDTIzMDIy 5 | NzEzMzg0OFoXDTMzMDIyNDEzMzg0OFowZTELMAkGA1UEBhMCY24xCzAJBgNVBAgM 6 | AmdkMQswCQYDVQQHDAJnejEPMA0GA1UECgwGYWNnaXN0MQ8wDQYDVQQLDAZ0YW95 7 | YW8xGjAYBgNVBAMMEXRhb3lhby5hY2dpc3QuY29tMIIBIjANBgkqhkiG9w0BAQEF 8 | AAOCAQ8AMIIBCgKCAQEAmeQvh6OwHR87DKvm04z1xjbHgh6fxi6y+5jMJ7K7LvPT 9 | l+7haNB/eeSgEnHL38Naaw2cQvNkSAVPK210q574tQZW6Am2icRb9EJnMx2tKdaG 10 | 8QtTGxddScebyO++7qzf8CwECPRpsZRRp1a5ompCouDXY4VWJatXBMnZX05ZqUJH 11 | 0u6nioDwvd+YBOui4nGCxoF8tcVsidvHWx0JTfC7simyMp/5VvVYt7V4ENuU+3NT 12 | wDF7sEW1z8Sx1ErE4NLQIyy+PpGmV+h2HgNb0Bnre+jq7v/1Ue2Irsd6xe9iHf3P 13 | ji/mnkrRdAxd36KszFvmQjLAClJM1tRjc7gGyO8yCQIDAQABo4GSMIGPMAsGA1Ud 14 | DwQEAwIF4DAdBgNVHSUEFjAUBggrBgEFBQcDAQYIKwYBBQUHAwIwYQYDVR0RBFow 15 | WIcEfwAAAYcEwKgBZIcEwKgBbocEwKgIZIcEwKgIboIJbG9jYWxob3N0ggphY2dp 16 | c3QuY29tgg53d3cuYWNnaXN0LmNvbYIRdGFveWFvLmFjZ2lzdC5jb20wDQYJKoZI 17 | hvcNAQELBQADggEBAKDYyUUMFDchfTYwEhUWHHtUpJTzVz2opAoKjUU2yH4pT4dT 18 | Fb1s4NAuopoU9ycX4MJaApmxMioWwQzkoBLbnr+4RPfOYR9nlU0s+dx5JcpOgJtR 19 | 6X08ZDmW2DqhfIqR89uvIOgOU0oc6nUxQ0+doihDYyuyvXkvkZLjl8hrv6phuL8e 20 | qhtx9++4umD3RYbRsASRmB8/iYTgi7WAvFyNM9kkS5pwkJOaHN+vtKx5xpytEROT 21 | pbdUgGdXcYzYwzqDJ7Wbe0pIKeZ97rx6mF+0/92sWhd2U54jn5M1gp1sCQqG/syd 22 | tER+0jG77mvqkls5VCNmUE1+pOa53MvB5TuTTsA= 23 | -----END CERTIFICATE----- 24 | -------------------------------------------------------------------------------- /taoyao-client-web/src/main.js: -------------------------------------------------------------------------------- 1 | import App from "./App.vue"; 2 | import ElementPlus from "element-plus"; 3 | import { createApp } from "vue"; 4 | import "./assets/main.css"; 5 | import "element-plus/dist/index.css"; 6 | 7 | const app = createApp(App); 8 | app.use(ElementPlus); 9 | app.mount("#app"); 10 | 11 | console.info(` 12 | 中庭地白树栖鸦,冷露无声湿桂花。 13 | 今夜月明人尽望,不知秋思落谁家。 14 | 15 | :: https://gitee.com/acgist/taoyao 16 | `); 17 | -------------------------------------------------------------------------------- /taoyao-client-web/vite.config.js: -------------------------------------------------------------------------------- 1 | import fs from "node:fs"; 2 | import vue from "@vitejs/plugin-vue"; 3 | import { defineConfig } from "vite"; 4 | import { fileURLToPath, URL } from "node:url"; 5 | 6 | export default defineConfig({ 7 | server: { 8 | port : 8443, 9 | host : "0.0.0.0", 10 | https: { 11 | key : fs.readFileSync("src/certs/server.key"), 12 | cert: fs.readFileSync("src/certs/server.crt"), 13 | }, 14 | }, 15 | plugins: [ vue() ], 16 | resolve: { 17 | alias: { 18 | "@": fileURLToPath(new URL("./src", import.meta.url)), 19 | }, 20 | }, 21 | }); 22 | 23 | console.info(` 24 | 中庭地白树栖鸦,冷露无声湿桂花。 25 | 今夜月明人尽望,不知秋思落谁家。 26 | 27 | :: https://gitee.com/acgist/taoyao 28 | `); 29 | -------------------------------------------------------------------------------- /taoyao-signal-server/docs/bin/deploy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ######################### 4 | # 部署任务 # 5 | ######################### 6 | 7 | # 进入目录 8 | base=$(readlink -f $(dirname $0)) 9 | cd $base 10 | echo "环境目录:$base" 11 | echo "当前目录:$(pwd)" 12 | 13 | # 更新代码 14 | echo "更新代码:${project.artifactId}-${project.version}" 15 | git pull 16 | 17 | # 编译代码 18 | echo "编译代码:${project.artifactId}-${project.version}" 19 | mvn clean package -D skipTests -P ${profile} 20 | # 编译指定模块以及依赖 21 | # mvn clean package -pl "${project.groupId}:${project.artifactId}" -am -D skipTests -P ${profile} 22 | 23 | # 删除文件 24 | rm -rf $base/deploy/bin 25 | rm -rf $base/deploy/lib 26 | rm -rf $base/deploy/config 27 | 28 | # 运行目录 29 | echo "拷贝文件:${project.artifactId}-${project.version}" 30 | if [ ! -d "$base/deploy" ]; then 31 | mkdir -p $base/deploy 32 | fi 33 | 34 | # 拷贝文件 35 | cp -rf ${project.basedir}/target/${project.artifactId}-${project.version}/* $base/deploy 36 | 37 | # 启动服务 38 | echo "启动项目:${project.artifactId}-${project.version}" 39 | sudo systemctl restart taoyao-signal-server 40 | sudo systemctl status taoyao-signal-server 41 | -------------------------------------------------------------------------------- /taoyao-signal-server/docs/bin/stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ######################### 4 | # 结束任务 # 5 | ######################### 6 | 7 | killIndex=0 8 | processId=$(ps -aux | grep "${project.artifactId}" | grep java | awk '{print $2}') 9 | if [ ! -z "$processId" ]; then 10 | echo "关闭应用:${project.artifactId}-${project.version} - $processId" 11 | while [ ! -z "$processId" ] 12 | do 13 | echo -n "." 14 | if [ $killIndex -le 0 ]; then 15 | # 优雅关机 16 | kill -15 $processId 17 | elif [ $killIndex -ge 10 ]; then 18 | # 强制关机 19 | echo -n "强制关闭" 20 | kill -9 $processId 21 | fi 22 | sleep 1 23 | killIndex=$((killIndex+1)) 24 | processId=$(ps -aux | grep "${project.artifactId}" | grep java | awk '{print $2}') 25 | done 26 | echo "" 27 | fi 28 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 4.0.0 6 | 7 | 8 | com.acgist 9 | taoyao 10 | 1.0.0 11 | 12 | 13 | taoyao-boot 14 | jar 15 | 16 | taoyao-boot 17 | 基础模块 18 | 19 | 20 | 21 | org.springframework.boot 22 | spring-boot-starter-web 23 | true 24 | 25 | 26 | org.springframework.boot 27 | spring-boot-starter-websocket 28 | true 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/main/java/com/acgist/taoyao/boot/annotation/Description.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.annotation; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Inherited; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | /** 11 | * 信令描述 12 | * 13 | * -[消息类型]> 异步请求 | 单播消息 14 | * =[消息类型]> 同步请求:到达目标终端后沿原路返回 15 | * -[消息类型]) 全员广播:对所有的终端广播信令(排除自己) 16 | * +[消息类型]) 全员广播:对所有的终端广播信令(包含自己) 17 | * 18 | * 消息类型可以省略表示和前面一致 19 | * 20 | * @author acgist 21 | */ 22 | @Target(ElementType.TYPE) 23 | @Inherited 24 | @Retention(RetentionPolicy.RUNTIME) 25 | @Documented 26 | public @interface Description { 27 | 28 | /** 29 | * @return 消息主体 30 | */ 31 | String[] body() default "{}"; 32 | 33 | /** 34 | * @return 数据流向 35 | */ 36 | String[] flow() default "终端->信令服务->终端"; 37 | 38 | /** 39 | * @return 详细描述 40 | */ 41 | String memo() default ""; 42 | 43 | } 44 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/main/java/com/acgist/taoyao/boot/annotation/Listener.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.annotation; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import org.springframework.stereotype.Component; 10 | 11 | /** 12 | * 监听器 13 | * 14 | * @author acgist 15 | */ 16 | @Target(ElementType.TYPE) 17 | @Component 18 | @Retention(RetentionPolicy.RUNTIME) 19 | @Documented 20 | public @interface Listener { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/main/java/com/acgist/taoyao/boot/annotation/Manager.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.annotation; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import org.springframework.stereotype.Component; 10 | 11 | /** 12 | * 管理器 13 | * 14 | * @author acgist 15 | */ 16 | @Target(ElementType.TYPE) 17 | @Component 18 | @Retention(RetentionPolicy.RUNTIME) 19 | @Documented 20 | public @interface Manager { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/main/java/com/acgist/taoyao/boot/annotation/Protocol.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.annotation; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | import org.springframework.stereotype.Component; 10 | 11 | /** 12 | * 信令 13 | * 14 | * @author acgist 15 | */ 16 | @Target(ElementType.TYPE) 17 | @Component 18 | @Retention(RetentionPolicy.RUNTIME) 19 | @Documented 20 | public @interface Protocol { 21 | 22 | } 23 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/main/java/com/acgist/taoyao/boot/config/IdProperties.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | 5 | import io.swagger.v3.oas.annotations.media.Schema; 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | /** 10 | * ID配置 11 | * 12 | * 服务端:日期 + 两位机器序号 + 六位索引 13 | * 范围:00000000~09999999 14 | * 并发:1000000 / S 15 | * 16 | * 终端:日期 + 五位机器序号 + 三位索引 17 | * 范围:10000000~99999999 18 | * 并发:1000 / S 19 | * 20 | * @author acgist 21 | */ 22 | @Getter 23 | @Setter 24 | @Schema(title = "ID配置", description = "ID配置") 25 | @ConfigurationProperties(prefix = "taoyao.id") 26 | public class IdProperties { 27 | 28 | @Schema(title = "最大序号", description = "最大序号") 29 | private Integer maxIndex; 30 | @Schema(title = "机器序号", description = "机器序号") 31 | private Integer serverIndex; 32 | @Schema(title = "最小终端序号", description = "最小终端序号") 33 | private Integer minClientIndex; 34 | @Schema(title = "最大终端序号", description = "最大终端序号") 35 | private Integer maxClientIndex; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/main/java/com/acgist/taoyao/boot/config/MediaAudioProperties.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.config; 2 | 3 | import io.swagger.v3.oas.annotations.media.Schema; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | /** 8 | * 音频配置 9 | * 10 | * 比特率 = 采样率 * 采样位数 * 声道数 / 8 / 1024 11 | * 12 | * @author acgist 13 | */ 14 | @Getter 15 | @Setter 16 | @Schema(title = "音频配置", description = "音频配置") 17 | public class MediaAudioProperties { 18 | 19 | /** 20 | * 音频格式 21 | * 22 | * @author acgist 23 | */ 24 | public enum Format { 25 | 26 | // G722 27 | G722, 28 | // G711A 29 | PCMA, 30 | // G711U 31 | PCMU, 32 | // OPUS 33 | OPUS; 34 | 35 | } 36 | 37 | @Schema(title = "格式", description = "格式", example = "G722|PCMA|PCMU|OPUS") 38 | private Format format; 39 | @Schema(title = "比特率", description = "比特率", example = "96|128|256") 40 | private Integer bitrate; 41 | @Schema(title = "采样位数(位深)", description = "采样位数(位深)", example = "8|16|32") 42 | private Integer sampleSize; 43 | @Schema(title = "采样率", description = "采样率", example = "8000|16000|32000|48000") 44 | private Integer sampleRate; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/main/java/com/acgist/taoyao/boot/config/RewriteProperties.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.config; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.boot.context.properties.ConfigurationProperties; 6 | 7 | import io.swagger.v3.oas.annotations.media.Schema; 8 | import lombok.Getter; 9 | import lombok.Setter; 10 | 11 | /** 12 | * 地址重写配置 13 | * 用于多网卡多子网复杂网络环境自动适配IP地址 14 | * 15 | * @author acgist 16 | */ 17 | @Getter 18 | @Setter 19 | @Schema(title = "地址重写", description = "地址重写") 20 | @ConfigurationProperties(prefix = "taoyao.rewrite") 21 | public class RewriteProperties { 22 | 23 | @Schema(title = "是否启用", description = "是否启用") 24 | private Boolean enabled; 25 | @Schema(title = "子网掩码", description = "子网掩码:主机号的长度") 26 | private Integer prefix; 27 | @Schema(title = "重写规则", description = "重写规则") 28 | private List rule; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/main/java/com/acgist/taoyao/boot/config/RewriteRuleProperties.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.config; 2 | 3 | import io.swagger.v3.oas.annotations.media.Schema; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | /** 8 | * 重写规则 9 | * 配置内网地址直接返回内网地址 10 | * 没有配置内网地址内网地址等于网络号加上原始主机号 11 | * 12 | * 内网设备IP返回内网地址 13 | * 外网设备IP返回外网地址 14 | * 15 | * @author acgist 16 | */ 17 | @Getter 18 | @Setter 19 | @Schema(title = "重写规则", description = "重写规则") 20 | public class RewriteRuleProperties { 21 | 22 | @Schema(title = "网络号", description = "网络号:匹配终端IP") 23 | private String network; 24 | @Schema(title = "内网地址", description = "内网地址") 25 | private String innerHost; 26 | @Schema(title = "外网地址", description = "外网地址") 27 | private String outerHost; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/main/java/com/acgist/taoyao/boot/config/ScriptProperties.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | 5 | import io.swagger.v3.oas.annotations.media.Schema; 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | /** 10 | * 脚本配置 11 | * 12 | * @author acgist 13 | */ 14 | @Getter 15 | @Setter 16 | @Schema(title = "脚本配置", description = "脚本配置") 17 | @ConfigurationProperties(prefix = "taoyao.script") 18 | public class ScriptProperties { 19 | 20 | @Schema(title = "是否启用", description = "是否启用") 21 | private Boolean enabled; 22 | @Schema(title = "重启系统", description = "重启系统") 23 | private String systemReboot; 24 | @Schema(title = "关闭系统", description = "关闭系统") 25 | private String systemShutdown; 26 | @Schema(title = "重启平台", description = "重启平台") 27 | private String platformReboot; 28 | @Schema(title = "关闭平台", description = "关闭平台") 29 | private String platformShutdown; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/main/java/com/acgist/taoyao/boot/config/SecurityProperties.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | 5 | import io.swagger.v3.oas.annotations.media.Schema; 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | /** 10 | * 安全配置 11 | * 注意:没有配置`UsernamePasswordService`使用帐号密码 12 | * 13 | * @author acgist 14 | */ 15 | @Getter 16 | @Setter 17 | @Schema(title = "安全配置", description = "安全配置") 18 | @ConfigurationProperties(prefix = "taoyao.security") 19 | public class SecurityProperties { 20 | 21 | @Schema(title = "是否启用", description = "是否启用") 22 | private Boolean enabled; 23 | @Schema(title = "安全范围", description = "安全范围") 24 | private String realm; 25 | @Schema(title = "公共地址", description = "公共地址") 26 | private String[] permit; 27 | @Schema(title = "帐号", description = "帐号") 28 | private String username; 29 | @Schema(title = "密码", description = "密码") 30 | private String password; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/main/java/com/acgist/taoyao/boot/config/TaoyaoProperties.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.config; 2 | 3 | import org.springframework.boot.context.properties.ConfigurationProperties; 4 | 5 | import io.swagger.v3.oas.annotations.media.Schema; 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | /** 10 | * 平台配置 11 | * 12 | * @author acgist 13 | */ 14 | @Getter 15 | @Setter 16 | @Schema(title = "平台配置", description = "平台配置") 17 | @ConfigurationProperties(prefix = "taoyao") 18 | public class TaoyaoProperties { 19 | 20 | @Schema(title = "项目地址", description = "项目地址") 21 | private String url; 22 | @Schema(title = "项目名称", description = "项目名称") 23 | private String name; 24 | @Schema(title = "项目版本", description = "项目版本") 25 | private String version; 26 | @Schema(title = "项目描述", description = "项目描述") 27 | private String description; 28 | @Schema(title = "超时时间", description = "超时时间") 29 | private Long timeout; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/main/java/com/acgist/taoyao/boot/config/WebrtcStunProperties.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.config; 2 | 3 | import io.swagger.v3.oas.annotations.media.Schema; 4 | import lombok.EqualsAndHashCode; 5 | import lombok.Getter; 6 | import lombok.Setter; 7 | 8 | /** 9 | * WebRTC STUN配置 10 | * 11 | * @author acgist 12 | */ 13 | @Getter 14 | @Setter 15 | @Schema(title = "WebRTC STUN配置", description = "WebRTC STUN配置") 16 | @EqualsAndHashCode(of = { "host", "port" }) 17 | public class WebrtcStunProperties { 18 | 19 | @Schema(title = "主机", description = "主机") 20 | protected String host; 21 | @Schema(title = "端口", description = "端口") 22 | protected Integer port; 23 | 24 | @Schema(title = "完整地址", description = "完整地址") 25 | public String getAddress() { 26 | return "stun:" + this.host + ":" + this.port; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/main/java/com/acgist/taoyao/boot/config/WebrtcTurnProperties.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.config; 2 | 3 | import io.swagger.v3.oas.annotations.media.Schema; 4 | import lombok.EqualsAndHashCode; 5 | import lombok.Getter; 6 | import lombok.Setter; 7 | 8 | /** 9 | * WebRTC TURN配置 10 | * 11 | * @author acgist 12 | */ 13 | @Getter 14 | @Setter 15 | @Schema(title = "WebRTC TURN配置", description = "WebRTC TURN配置") 16 | @EqualsAndHashCode(callSuper = true) 17 | public class WebrtcTurnProperties extends WebrtcStunProperties { 18 | 19 | @Schema(title = "帐号", description = "帐号") 20 | private String username; 21 | @Schema(title = "密码", description = "密码") 22 | private String password; 23 | 24 | @Override 25 | @Schema(title = "完整地址", description = "完整地址") 26 | public String getAddress() { 27 | return "turn:" + this.host + ":" + this.port; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/main/java/com/acgist/taoyao/boot/controller/TaoyaoControllerAdvice.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.controller; 2 | 3 | import org.springframework.web.bind.annotation.ExceptionHandler; 4 | import org.springframework.web.bind.annotation.RestControllerAdvice; 5 | 6 | import com.acgist.taoyao.boot.model.Message; 7 | import com.acgist.taoyao.boot.utils.ErrorUtils; 8 | 9 | import io.swagger.v3.oas.annotations.Operation; 10 | import io.swagger.v3.oas.annotations.tags.Tag; 11 | import jakarta.servlet.http.HttpServletRequest; 12 | import jakarta.servlet.http.HttpServletResponse; 13 | 14 | /** 15 | * 统一异常处理 16 | * 17 | * 不能处理:https://localhost:8888/?\%3E%3C 18 | * 19 | * @author acgist 20 | */ 21 | @Tag(name = "统一异常处理", description = "全局统一异常处理") 22 | @RestControllerAdvice 23 | public class TaoyaoControllerAdvice { 24 | 25 | @Operation(summary = "统一异常处理", description = "全局统一异常处理") 26 | @ExceptionHandler(Exception.class) 27 | public Message exception(Exception e, HttpServletRequest request, HttpServletResponse response) { 28 | return ErrorUtils.message(e, request, response); 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/main/java/com/acgist/taoyao/boot/controller/TaoyaoErrorController.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.controller; 2 | 3 | import org.springframework.boot.web.servlet.error.ErrorController; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RestController; 6 | 7 | import com.acgist.taoyao.boot.model.Message; 8 | import com.acgist.taoyao.boot.utils.ErrorUtils; 9 | 10 | import io.swagger.v3.oas.annotations.Operation; 11 | import io.swagger.v3.oas.annotations.tags.Tag; 12 | import jakarta.servlet.http.HttpServletRequest; 13 | import jakarta.servlet.http.HttpServletResponse; 14 | 15 | /** 16 | * 统一错误页面 17 | * 18 | * @author acgist 19 | */ 20 | @Tag(name = "统一错误页面", description = "全局统一错误页面") 21 | @RestController 22 | public class TaoyaoErrorController implements ErrorController { 23 | 24 | @Operation(summary = "统一错误页面", description = "全局统一错误页面") 25 | @RequestMapping(value = ErrorUtils.ERROR_PATH) 26 | public Message index(HttpServletRequest request, HttpServletResponse response) { 27 | return ErrorUtils.message(request, response); 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/main/java/com/acgist/taoyao/boot/interceptor/InterceptorAdapter.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.interceptor; 2 | 3 | import org.springframework.core.Ordered; 4 | import org.springframework.web.servlet.HandlerInterceptor; 5 | 6 | /** 7 | * MVC拦截器适配器 8 | * 9 | * @author acgist 10 | */ 11 | public abstract class InterceptorAdapter implements Ordered, Comparable, HandlerInterceptor { 12 | 13 | /** 14 | * @return 名称 15 | */ 16 | public abstract String name(); 17 | 18 | /** 19 | * @return 拦截地址 20 | */ 21 | public abstract String[] pathPattern(); 22 | 23 | @Override 24 | public int compareTo(InterceptorAdapter target) { 25 | return Integer.compare(this.getOrder(), target.getOrder()); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/main/java/com/acgist/taoyao/boot/model/Header.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.model; 2 | 3 | import java.io.Serializable; 4 | 5 | import io.swagger.v3.oas.annotations.media.Schema; 6 | import lombok.AllArgsConstructor; 7 | import lombok.Builder; 8 | import lombok.Getter; 9 | import lombok.NoArgsConstructor; 10 | import lombok.Setter; 11 | 12 | /** 13 | * 消息头部 14 | * 15 | * @author acgist 16 | */ 17 | @Getter 18 | @Setter 19 | @Schema(title = "消息头部", description = "消息头部") 20 | @Builder 21 | @NoArgsConstructor 22 | @AllArgsConstructor 23 | public class Header implements Cloneable, Serializable { 24 | 25 | private static final long serialVersionUID = 1L; 26 | 27 | /** 28 | * 消息版本 29 | */ 30 | @Schema(title = "消息版本", description = "消息版本") 31 | private String v; 32 | /** 33 | * 消息标识 34 | */ 35 | @Schema(title = "消息标识", description = "消息标识") 36 | private Long id; 37 | /** 38 | * 信令标识 39 | */ 40 | @Schema(title = "信令标识", description = "信令标识") 41 | private String signal; 42 | 43 | @Override 44 | public Header clone() { 45 | return new Header(this.v, this.id, this.signal); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/main/java/com/acgist/taoyao/boot/model/MessageMapstruct.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.model; 2 | 3 | import org.mapstruct.Mapper; 4 | import org.mapstruct.MappingConstants.ComponentModel; 5 | import org.mapstruct.MappingTarget; 6 | 7 | @Mapper(componentModel = ComponentModel.SPRING) 8 | public interface MessageMapstruct { 9 | 10 | /** 11 | * 对象拷贝 12 | * 13 | * @param source 原始对象 14 | * 15 | * @return 目标对象 16 | */ 17 | Header copy(Header source); 18 | 19 | /** 20 | * 对象拷贝 21 | * 22 | * @param source 原始对象 23 | * @param target 目标对象 24 | */ 25 | void copy(Header source, @MappingTarget Header target); 26 | 27 | /** 28 | * 对象拷贝 29 | * 30 | * @param source 原始对象 31 | * 32 | * @return 目标对象 33 | */ 34 | Message copy(Message source); 35 | 36 | /** 37 | * 对象拷贝 38 | * 39 | * @param source 原始对象 40 | * @param target 目标对象 41 | */ 42 | void copy(Message source, @MappingTarget Message target); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/main/java/com/acgist/taoyao/boot/runner/OrderedCommandLineRunner.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.runner; 2 | 3 | import org.springframework.boot.CommandLineRunner; 4 | import org.springframework.core.Ordered; 5 | 6 | /** 7 | * Ordered + CommandLineRunner 8 | * 9 | * @author acgist 10 | */ 11 | public interface OrderedCommandLineRunner extends Ordered, CommandLineRunner { 12 | 13 | @Override 14 | default int getOrder() { 15 | return 0; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/main/java/com/acgist/taoyao/boot/service/IdService.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.service; 2 | 3 | /** 4 | * 生成ID服务 5 | * 6 | * @author acgist 7 | */ 8 | public interface IdService { 9 | 10 | /** 11 | * 生成十六位的消息ID:ddHHmmss(8) + index(2) + xxxxxx(6) 12 | * 只能用于生成消息ID:JS超过`Number.MAX_SAFE_INTEGER`丢失精度 13 | * 14 | * @return ID 15 | */ 16 | long buildId(); 17 | 18 | /** 19 | * @return 终端索引 20 | */ 21 | long buildClientIndex(); 22 | 23 | /** 24 | * 生成三十二位唯一ID 25 | * 26 | * @return ID 27 | */ 28 | String buildUuid(); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports: -------------------------------------------------------------------------------- 1 | com.acgist.taoyao.boot.configuration.BootAutoConfiguration 2 | com.acgist.taoyao.boot.configuration.SpringDocAutoConfiguration 3 | com.acgist.taoyao.boot.configuration.WebMvcConfigurerAutoConfiguration 4 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/main/resources/banner.txt: -------------------------------------------------------------------------------- 1 | ___ ___ ___ ___ ___ ___ 2 | /\ \ /\ \ /\ \ /\__\ /\ \ /\ \ 3 | \:\ \ /::\ \ /::\ \ |::L__L /::\ \ /::\ \ 4 | /::\__\ /::\:\__\ /:/\:\__\ |:::\__\ /::\:\__\ /:/\:\__\ 5 | /:/\/__/ \/\::/ / \:\/:/ / /:;;/__/ \/\::/ / \:\/:/ / 6 | \/__/ /:/ / \::/ / \/__/ /:/ / \::/ / 7 | \/__/ \/__/ \/__/ \/__/ 8 | 9 | :: Spring Boot : ${spring-boot.formatted-version} 10 | :: ${spring.application.name} : https://gitee.com/acgist/taoyao 11 | 12 | 去年今日此门中,人面桃花相映红。 13 | 人面不知何处去,桃花依旧笑春风。 14 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/test/java/com/acgist/taoyao/boot/model/MessageTest.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.model; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | 5 | import java.util.Map; 6 | 7 | import org.junit.jupiter.api.Test; 8 | 9 | import com.acgist.taoyao.boot.utils.JSONUtils; 10 | 11 | import lombok.extern.slf4j.Slf4j; 12 | 13 | @Slf4j 14 | public class MessageTest { 15 | 16 | @Test 17 | public void testJSON() { 18 | final Message message = Message.builder() 19 | .code("0000") 20 | .message("acgist") 21 | .body(Map.of("1", "2")) 22 | .build(); 23 | final String json = JSONUtils.toJSON(message); 24 | assertEquals("{\"code\":\"0000\",\"message\":\"acgist\",\"body\":{\"1\":\"2\"}}", json); 25 | log.info("{}", json); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/test/java/com/acgist/taoyao/boot/utils/FileUtilsTest.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.utils; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | 5 | import org.junit.jupiter.api.Test; 6 | 7 | import lombok.extern.slf4j.Slf4j; 8 | 9 | @Slf4j 10 | public class FileUtilsTest { 11 | 12 | @Test 13 | void test() { 14 | assertEquals("0B", FileUtils.formatSize(0L)); 15 | assertEquals("0B", FileUtils.formatSize(-10L)); 16 | assertEquals("1.00KB", FileUtils.formatSize(1024L)); 17 | log.info("{}", FileUtils.formatSize(1025L)); 18 | log.info("{}", FileUtils.formatSize(2025L)); 19 | log.info("{}", FileUtils.formatSize(Long.MAX_VALUE)); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/test/java/com/acgist/taoyao/boot/utils/HTTPUtilsTest.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.utils; 2 | 3 | import java.io.IOException; 4 | import java.net.URI; 5 | import java.net.http.HttpClient; 6 | import java.net.http.HttpRequest; 7 | import java.net.http.HttpResponse; 8 | import java.net.http.HttpResponse.BodyHandlers; 9 | import java.util.concurrent.Executors; 10 | 11 | import org.junit.jupiter.api.Test; 12 | 13 | import lombok.extern.slf4j.Slf4j; 14 | 15 | @Slf4j 16 | public class HTTPUtilsTest { 17 | 18 | @Test 19 | void test() throws IOException, InterruptedException { 20 | HTTPUtils.init(5000, Executors.newCachedThreadPool()); 21 | final HttpClient client = HTTPUtils.newClient(); 22 | final HttpResponse response = client.send( 23 | HttpRequest.newBuilder(URI.create("https://www.acgist.com")).GET().build(), 24 | BodyHandlers.ofString() 25 | ); 26 | log.info("{}", response.body()); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-boot/src/test/java/com/acgist/taoyao/boot/utils/ScriptUtilsTest.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.boot.utils; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | import static org.junit.jupiter.api.Assertions.assertNotEquals; 5 | 6 | import org.junit.jupiter.api.Test; 7 | 8 | import lombok.extern.slf4j.Slf4j; 9 | 10 | @Slf4j 11 | public class ScriptUtilsTest { 12 | 13 | @Test 14 | void test() throws InterruptedException { 15 | assertNotEquals(0, ScriptUtils.execute("ls").getCode()); 16 | assertEquals(0, ScriptUtils.execute("netstat -ano").getCode()); 17 | log.info("{}", ScriptUtils.execute("ls").getResult()); 18 | log.info("{}", ScriptUtils.execute("netstat -ano").getResult()); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-server/src/main/java/com/acgist/taoyao/listener/QnjrcmzListener.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.listener; 2 | 3 | import org.springframework.boot.context.event.ApplicationStartingEvent; 4 | import org.springframework.context.ApplicationListener; 5 | import org.springframework.lang.NonNull; 6 | 7 | import lombok.extern.slf4j.Slf4j; 8 | 9 | /** 10 | * 去年今日此门中 11 | * 人面桃花相映红 12 | * 13 | * 注意:SpringApplicationRunListeners里面同步执行 14 | * 15 | * @author acgist 16 | */ 17 | @Slf4j 18 | public class QnjrcmzListener implements ApplicationListener { 19 | 20 | @Override 21 | public void onApplicationEvent(@NonNull ApplicationStartingEvent event) { 22 | synchronized (QnjrcmzListener.class) { 23 | log.debug("配置忽略证书域名校验"); 24 | // 配置JDK HTTPClient域名校验问题 25 | System.getProperties().setProperty("jdk.internal.httpclient.disableHostnameVerification", Boolean.TRUE.toString()); 26 | } 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-server/src/main/java/com/acgist/taoyao/listener/ThyjxcfListener.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.listener; 2 | 3 | import org.springframework.boot.context.event.ApplicationReadyEvent; 4 | import org.springframework.context.ApplicationListener; 5 | import org.springframework.lang.NonNull; 6 | 7 | import com.acgist.taoyao.boot.annotation.Listener; 8 | import com.acgist.taoyao.boot.config.TaoyaoProperties; 9 | 10 | import lombok.extern.slf4j.Slf4j; 11 | 12 | /** 13 | * 人面不知何处去 14 | * 桃花依旧笑春风 15 | * 16 | * @author acgist 17 | */ 18 | @Slf4j 19 | @Listener 20 | public class ThyjxcfListener implements ApplicationListener { 21 | 22 | @Override 23 | public void onApplicationEvent(@NonNull ApplicationReadyEvent event) { 24 | synchronized (ThyjxcfListener.class) { 25 | final TaoyaoProperties taoyaoProperties = event.getApplicationContext().getBean(TaoyaoProperties.class); 26 | log.info("项目启动成功:{}", taoyaoProperties.getName()); 27 | } 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-server/src/main/java/com/acgist/taoyao/main/TaoyaoApplication.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.main; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.context.annotation.ComponentScan; 6 | 7 | @ComponentScan(basePackages = "com.acgist.taoyao") 8 | @SpringBootApplication 9 | public class TaoyaoApplication { 10 | 11 | public static void main(String[] args) { 12 | SpringApplication.run(TaoyaoApplication.class, args); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-server/src/main/resources/META-INF/spring.factories: -------------------------------------------------------------------------------- 1 | org.springframework.context.ApplicationListener=com.acgist.taoyao.listener.QnjrcmzListener 2 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-server/src/main/resources/application-dev.yml: -------------------------------------------------------------------------------- 1 | server: 2 | # 使用反向代理建议不要配置HTTPS 3 | ssl: 4 | key-alias: taoyao 5 | key-store: classpath:server.p12 6 | key-store-type: PKCS12 7 | key-store-password: 123456 8 | key-password: 123456 9 | taoyao: 10 | security: 11 | permit: 12 | - / 13 | - /error 14 | - /index.html 15 | - /favicon.ico 16 | - /v3/api-docs/** 17 | - /swagger-ui/** 18 | - /swagger-ui.html 19 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-server/src/main/resources/application-prd.yml: -------------------------------------------------------------------------------- 1 | taoyao: 2 | security: 3 | password: ${random.uuid} 4 | script: 5 | enabled: false 6 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-server/src/main/resources/application-win.yml: -------------------------------------------------------------------------------- 1 | taoyao: 2 | script: 3 | system-reboot: shutdown /r /t 0 4 | system-shutdown: shutdown /s /t 0 5 | platform-reboot: net stop taoyao-signal-server && net start taoyao-signal-server 6 | platform-shutdown: net stop taoyao-signal-server -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-server/src/main/resources/server.p12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-signal-server/taoyao-server/src/main/resources/server.p12 -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-server/src/main/resources/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/acgist/taoyao/2d065876db331eb4329639c96986b18e154b4d3e/taoyao-signal-server/taoyao-server/src/main/resources/static/favicon.ico -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-server/src/main/resources/static/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 桃夭信令服务 6 | 10 | 11 | 12 |

taoyao-signal-server

13 |

acgist

14 | 15 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-server/src/test/java/com/acgist/taoyao/annotation/CostedTest.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.annotation; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Inherited; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | import java.util.concurrent.TimeUnit; 10 | 11 | /** 12 | * 多线程测试 13 | * 14 | * @author acgist 15 | */ 16 | @Target(ElementType.METHOD) 17 | @Inherited 18 | @Retention(RetentionPolicy.RUNTIME) 19 | @Documented 20 | public @interface CostedTest { 21 | 22 | /** 23 | * @return 执行次数 24 | */ 25 | int count() default 1; 26 | 27 | /** 28 | * @return 线程数量 29 | */ 30 | int thread() default 1; 31 | 32 | /** 33 | * @return 超时时间 34 | */ 35 | long timeout() default 1000L; 36 | 37 | /** 38 | * @return 等待资源释放时间 39 | */ 40 | long waitRelease() default 0L; 41 | 42 | /** 43 | * @return 超时时间单位 44 | */ 45 | TimeUnit timeUnit() default TimeUnit.MILLISECONDS; 46 | 47 | } 48 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-server/src/test/java/com/acgist/taoyao/annotation/TaoyaoTest.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.annotation; 2 | 3 | import java.lang.annotation.Documented; 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Inherited; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | import org.springframework.boot.test.context.SpringBootTest; 11 | import org.springframework.core.annotation.AliasFor; 12 | import org.springframework.test.context.TestExecutionListeners; 13 | import org.springframework.test.context.TestExecutionListeners.MergeMode; 14 | 15 | /** 16 | * 测试启动 17 | * 18 | * @author acgist 19 | */ 20 | @Target(ElementType.TYPE) 21 | @Inherited 22 | @Retention(RetentionPolicy.RUNTIME) 23 | @Documented 24 | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) 25 | @TestExecutionListeners(listeners = CostedTestTestExecutionListener.class, mergeMode = MergeMode.MERGE_WITH_DEFAULTS) 26 | public @interface TaoyaoTest { 27 | 28 | @AliasFor(annotation = SpringBootTest.class) 29 | Class[] classes() default {}; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-server/src/test/java/com/acgist/taoyao/service/IdServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.service; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | 6 | import com.acgist.taoyao.annotation.CostedTest; 7 | import com.acgist.taoyao.annotation.TaoyaoTest; 8 | import com.acgist.taoyao.boot.service.IdService; 9 | import com.acgist.taoyao.main.TaoyaoApplication; 10 | 11 | import lombok.extern.slf4j.Slf4j; 12 | 13 | @Slf4j 14 | @TaoyaoTest(classes = TaoyaoApplication.class) 15 | //@SpringBootTest(classes = TaoyaoApplication.class, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) 16 | class IdServiceTest { 17 | 18 | @Autowired 19 | private IdService idService; 20 | 21 | @Test 22 | // @Timeout(value = 1000, unit = TimeUnit.MILLISECONDS) 23 | // @Rollback() 24 | // @RepeatedTest(10) 25 | void testId() { 26 | final long id = this.idService.buildId(); 27 | log.info("生成ID:{}", id); 28 | log.info("生成ID:{}", String.valueOf(id).length()); 29 | } 30 | 31 | @Test 32 | @CostedTest(count = 100000, thread = 10) 33 | void testIdCosted() { 34 | this.idService.buildId(); 35 | } 36 | 37 | @Test 38 | @CostedTest(count = 100000, thread = 10) 39 | void testUuidCosted() { 40 | this.idService.buildUuid(); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 4.0.0 6 | 7 | 8 | com.acgist 9 | taoyao 10 | 1.0.0 11 | 12 | 13 | taoyao-signal 14 | jar 15 | 16 | taoyao-signal 17 | 信令模块 18 | 19 | 20 | 21 | com.acgist 22 | taoyao-boot 23 | 24 | 25 | org.springframework.boot 26 | spring-boot-starter-web 27 | 28 | 29 | org.springframework.boot 30 | spring-boot-starter-websocket 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/client/ClientMapstruct.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.client; 2 | 3 | import org.mapstruct.Mapper; 4 | import org.mapstruct.MappingConstants.ComponentModel; 5 | import org.mapstruct.MappingTarget; 6 | 7 | @Mapper(componentModel = ComponentModel.SPRING) 8 | public interface ClientMapstruct { 9 | 10 | /** 11 | * 对象拷贝 12 | * 13 | * @param source 原始对象 14 | * 15 | * @return 目标对象 16 | */ 17 | ClientStatus copy(ClientStatus source); 18 | 19 | /** 20 | * 对象拷贝 21 | * 22 | * @param source 原始对象 23 | * @param target 目标对象 24 | */ 25 | void copy(ClientStatus source, @MappingTarget ClientStatus target); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/client/proxy/ProxyClient.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.client.proxy; 2 | 3 | /** 4 | * 下级信令服务代理终端 5 | * 6 | * @author acgist 7 | */ 8 | public class ProxyClient { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/client/websocket/WebSocketClient.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.client.websocket; 2 | 3 | import com.acgist.taoyao.boot.config.Constant; 4 | import com.acgist.taoyao.boot.model.Message; 5 | import com.acgist.taoyao.signal.client.ClientAdapter; 6 | 7 | import jakarta.websocket.Session; 8 | import lombok.extern.slf4j.Slf4j; 9 | 10 | /** 11 | * WebSocket终端 12 | * 13 | * @author acgist 14 | */ 15 | @Slf4j 16 | public class WebSocketClient extends ClientAdapter { 17 | 18 | public WebSocketClient(long timeout, Session instance) { 19 | super(timeout, instance); 20 | } 21 | 22 | @Override 23 | public void push(Message message) { 24 | synchronized (this.instance) { 25 | try { 26 | if(this.instance.isOpen()) { 27 | this.instance.getBasicRemote().sendText(message.toString(), true); 28 | } else { 29 | log.error("WebSocket终端已经关闭:{}", this.instance); 30 | } 31 | } catch (Exception e) { 32 | log.error("WebSocket终端发送消息异常:{}", message, e); 33 | } 34 | } 35 | } 36 | 37 | @Override 38 | protected String getClientIP(Session instance) { 39 | return (String) instance.getUserProperties().get(Constant.IP); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/client/websocket/WebSocketSignalConfigurator.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.client.websocket; 2 | 3 | import java.lang.reflect.Field; 4 | 5 | import org.apache.catalina.connector.RequestFacade; 6 | 7 | import com.acgist.taoyao.boot.config.Constant; 8 | import com.acgist.taoyao.boot.model.MessageCodeException; 9 | 10 | import jakarta.websocket.HandshakeResponse; 11 | import jakarta.websocket.server.HandshakeRequest; 12 | import jakarta.websocket.server.ServerEndpointConfig; 13 | 14 | /** 15 | * WebSocket信令配置 16 | * 17 | * @author acgist 18 | */ 19 | public class WebSocketSignalConfigurator extends ServerEndpointConfig.Configurator { 20 | 21 | @Override 22 | public void modifyHandshake(ServerEndpointConfig config, HandshakeRequest request, HandshakeResponse response) { 23 | try { 24 | final Field field = request.getClass().getDeclaredField(Constant.REQUEST); 25 | field.setAccessible(true); 26 | config.getUserProperties().put(Constant.IP, ((RequestFacade) field.get(request)).getRemoteAddr()); 27 | } catch (SecurityException | NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { 28 | throw MessageCodeException.of(e, "无效终端IP:" + request); 29 | } 30 | super.modifyHandshake(config, request, response); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/configuration/SignalAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.configuration; 2 | 3 | import org.springframework.boot.CommandLineRunner; 4 | import org.springframework.boot.autoconfigure.AutoConfiguration; 5 | import org.springframework.context.ApplicationContext; 6 | import org.springframework.context.annotation.Bean; 7 | 8 | import com.acgist.taoyao.boot.runner.OrderedCommandLineRunner; 9 | import com.acgist.taoyao.signal.event.EventPublisher; 10 | import com.acgist.taoyao.signal.protocol.ProtocolManager; 11 | 12 | import jakarta.annotation.PostConstruct; 13 | import lombok.RequiredArgsConstructor; 14 | 15 | /** 16 | * 信令自动配置 17 | * 18 | * @author acgist 19 | */ 20 | @AutoConfiguration 21 | @RequiredArgsConstructor 22 | public class SignalAutoConfiguration { 23 | 24 | private final ApplicationContext applicationContext; 25 | 26 | @PostConstruct 27 | public void init() { 28 | EventPublisher.setApplicationContext(this.applicationContext); 29 | } 30 | 31 | @Bean 32 | public CommandLineRunner signalCommandLineRunner(ProtocolManager protocolManager) { 33 | return new OrderedCommandLineRunner() { 34 | @Override 35 | public void run(String ... args) throws Exception { 36 | protocolManager.init(); 37 | } 38 | }; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/configuration/WebSocketSignalAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.configuration; 2 | 3 | import org.springframework.boot.autoconfigure.AutoConfiguration; 4 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 5 | import org.springframework.context.annotation.Bean; 6 | import org.springframework.web.socket.config.annotation.EnableWebSocket; 7 | import org.springframework.web.socket.server.standard.ServerEndpointExporter; 8 | 9 | import com.acgist.taoyao.signal.client.websocket.WebSocketSignal; 10 | 11 | /** 12 | * WebSocket信令自动配置 13 | * 14 | * @author acgist 15 | */ 16 | @EnableWebSocket 17 | @AutoConfiguration 18 | public class WebSocketSignalAutoConfiguration { 19 | 20 | @Bean 21 | @ConditionalOnMissingBean 22 | public WebSocketSignal webSocketSignal() { 23 | return new WebSocketSignal(); 24 | } 25 | 26 | @Bean 27 | @ConditionalOnMissingBean 28 | public ServerEndpointExporter serverEndpointExporter() { 29 | return new ServerEndpointExporter(); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/event/ClientEventAdapter.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.event; 2 | 3 | import java.util.Map; 4 | 5 | import com.acgist.taoyao.boot.model.Message; 6 | import com.acgist.taoyao.signal.client.Client; 7 | 8 | import lombok.Getter; 9 | 10 | /** 11 | * 终端事件适配器 12 | * 13 | * @author acgist 14 | */ 15 | @Getter 16 | public abstract class ClientEventAdapter extends ApplicationEventAdapter { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | /** 21 | * 终端 22 | */ 23 | private final Client client; 24 | /** 25 | * 终端标识 26 | */ 27 | private final String clientId; 28 | 29 | public ClientEventAdapter(Client client) { 30 | this(client, null, null); 31 | } 32 | 33 | public ClientEventAdapter(Client client, Message message) { 34 | this(client, message, null); 35 | } 36 | 37 | public ClientEventAdapter(Client client, Message message, Map body) { 38 | super(client, message, body); 39 | this.client = client; 40 | this.clientId = client.getClientId(); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/event/EventPublisher.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.event; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.ApplicationEvent; 5 | 6 | /** 7 | * 事件发布者 8 | * 9 | * @author acgist 10 | */ 11 | public class EventPublisher { 12 | 13 | /** 14 | * 上下文 15 | */ 16 | private static ApplicationContext applicationContext; 17 | 18 | /** 19 | * @param applicationContext 上下文 20 | */ 21 | public static final void setApplicationContext(ApplicationContext applicationContext) { 22 | EventPublisher.applicationContext = applicationContext; 23 | } 24 | 25 | /** 26 | * 发布事件 27 | * 28 | * @param event 事件 29 | */ 30 | public static final void publishEvent(ApplicationEvent event) { 31 | EventPublisher.applicationContext.publishEvent(event); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/event/RoomEventAdapter.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.event; 2 | 3 | import java.util.Map; 4 | 5 | import com.acgist.taoyao.boot.model.Message; 6 | import com.acgist.taoyao.signal.client.Client; 7 | import com.acgist.taoyao.signal.party.room.Room; 8 | 9 | import lombok.Getter; 10 | 11 | /** 12 | * 房间事件适配器 13 | * 14 | * @author acgist 15 | */ 16 | @Getter 17 | public class RoomEventAdapter extends ApplicationEventAdapter { 18 | 19 | private static final long serialVersionUID = 1L; 20 | 21 | /** 22 | * 房间 23 | */ 24 | private final Room room; 25 | 26 | public RoomEventAdapter(Room room) { 27 | this(room, null, null); 28 | } 29 | 30 | public RoomEventAdapter(Room room, Message message) { 31 | this(room, message, null); 32 | } 33 | 34 | public RoomEventAdapter(Room room, Message message, Map body) { 35 | super(room, message, body); 36 | this.room = room; 37 | } 38 | 39 | /** 40 | * @return 房间媒体服务终端 41 | */ 42 | public Client getMediaClient() { 43 | return this.room.getMediaClient(); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/event/SessionEventAdapter.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.event; 2 | 3 | import java.util.Map; 4 | 5 | import com.acgist.taoyao.boot.model.Message; 6 | import com.acgist.taoyao.signal.party.session.Session; 7 | 8 | import lombok.Getter; 9 | 10 | /** 11 | * 视频会话事件适配器 12 | * 13 | * @author acgist 14 | */ 15 | @Getter 16 | public abstract class SessionEventAdapter extends ApplicationEventAdapter { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | /** 21 | * 视频会话 22 | */ 23 | private final Session session; 24 | /** 25 | * 视频会话ID 26 | */ 27 | private final String sessionId; 28 | 29 | public SessionEventAdapter(Session session) { 30 | this(session, null, null); 31 | } 32 | 33 | public SessionEventAdapter(Session session, Message message) { 34 | this(session, message, null); 35 | } 36 | 37 | public SessionEventAdapter(Session session, Message message, Map body) { 38 | super(session, message, body); 39 | this.session = session; 40 | this.sessionId = session.getId(); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/event/client/ClientCloseEvent.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.event.client; 2 | 3 | import com.acgist.taoyao.signal.client.Client; 4 | import com.acgist.taoyao.signal.event.ClientEventAdapter; 5 | 6 | /** 7 | * 关闭终端事件 8 | * 9 | * @author acgist 10 | */ 11 | public class ClientCloseEvent extends ClientEventAdapter { 12 | 13 | private static final long serialVersionUID = 1L; 14 | 15 | public ClientCloseEvent(Client client) { 16 | super(client); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/event/client/ClientConfigEvent.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.event.client; 2 | 3 | import com.acgist.taoyao.signal.client.Client; 4 | import com.acgist.taoyao.signal.event.ClientEventAdapter; 5 | 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | /** 10 | * 终端配置事件 11 | * 12 | * @author acgist 13 | */ 14 | @Getter 15 | @Setter 16 | public class ClientConfigEvent extends ClientEventAdapter { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | public ClientConfigEvent(Client client) { 21 | super(client); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/event/client/ClientOfflineEvent.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.event.client; 2 | 3 | import com.acgist.taoyao.signal.client.Client; 4 | import com.acgist.taoyao.signal.event.ClientEventAdapter; 5 | 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | /** 10 | * 终端下线事件 11 | * 12 | * @author acgist 13 | */ 14 | @Getter 15 | @Setter 16 | public class ClientOfflineEvent extends ClientEventAdapter { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | public ClientOfflineEvent(Client client) { 21 | super(client); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/event/client/ClientOnlineEvent.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.event.client; 2 | 3 | import com.acgist.taoyao.signal.client.Client; 4 | import com.acgist.taoyao.signal.event.ClientEventAdapter; 5 | 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | /** 10 | * 终端上线事件 11 | * 12 | * @author acgist 13 | */ 14 | @Getter 15 | @Setter 16 | public class ClientOnlineEvent extends ClientEventAdapter { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | public ClientOnlineEvent(Client client) { 21 | super(client); 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/event/media/MediaConsumeEvent.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.event.media; 2 | 3 | import com.acgist.taoyao.signal.event.RoomEventAdapter; 4 | import com.acgist.taoyao.signal.party.media.Producer; 5 | import com.acgist.taoyao.signal.party.room.ClientWrapper; 6 | import com.acgist.taoyao.signal.party.room.Room; 7 | 8 | import lombok.Getter; 9 | import lombok.Setter; 10 | 11 | /** 12 | * 消费媒体事件 13 | * 14 | * @author acgist 15 | */ 16 | @Getter 17 | @Setter 18 | public class MediaConsumeEvent extends RoomEventAdapter { 19 | 20 | private static final long serialVersionUID = 1L; 21 | 22 | /** 23 | * 生产者 24 | */ 25 | private final Producer producer; 26 | /** 27 | * 消费者终端包装器 28 | */ 29 | private final ClientWrapper clientWrapper; 30 | 31 | public MediaConsumeEvent(Room room, Producer producer) { 32 | super(room); 33 | this.producer = producer; 34 | this.clientWrapper = null; 35 | } 36 | 37 | public MediaConsumeEvent(Room room, ClientWrapper clientWrapper) { 38 | super(room); 39 | this.producer = null; 40 | this.clientWrapper = clientWrapper; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/event/media/MediaConsumerCloseEvent.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.event.media; 2 | 3 | import com.acgist.taoyao.signal.event.RoomEventAdapter; 4 | import com.acgist.taoyao.signal.party.room.Room; 5 | 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | /** 10 | * 关闭消费者事件 11 | * 12 | * @author acgist 13 | */ 14 | @Getter 15 | @Setter 16 | public class MediaConsumerCloseEvent extends RoomEventAdapter { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | /** 21 | * 消费者ID 22 | */ 23 | private final String consumerId; 24 | 25 | public MediaConsumerCloseEvent(String consumerId, Room room) { 26 | super(room); 27 | this.consumerId = consumerId; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/event/media/MediaConsumerPauseEvent.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.event.media; 2 | 3 | import com.acgist.taoyao.signal.event.RoomEventAdapter; 4 | import com.acgist.taoyao.signal.party.room.Room; 5 | 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | /** 10 | * 暂停消费者事件 11 | * 12 | * @author acgist 13 | */ 14 | @Getter 15 | @Setter 16 | public class MediaConsumerPauseEvent extends RoomEventAdapter { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | /** 21 | * 消费者ID 22 | */ 23 | private final String consumerId; 24 | 25 | public MediaConsumerPauseEvent(String consumerId, Room room) { 26 | super(room); 27 | this.consumerId = consumerId; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/event/media/MediaConsumerResumeEvent.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.event.media; 2 | 3 | import com.acgist.taoyao.signal.event.RoomEventAdapter; 4 | import com.acgist.taoyao.signal.party.room.Room; 5 | 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | /** 10 | * 恢复消费者信令 11 | * 12 | * @author acgist 13 | */ 14 | @Getter 15 | @Setter 16 | public class MediaConsumerResumeEvent extends RoomEventAdapter { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | /** 21 | * 消费者ID 22 | */ 23 | private final String consumerId; 24 | 25 | public MediaConsumerResumeEvent(String consumerId, Room room) { 26 | super(room); 27 | this.consumerId = consumerId; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/event/media/MediaDataConsumerCloseEvent.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.event.media; 2 | 3 | import com.acgist.taoyao.signal.event.RoomEventAdapter; 4 | import com.acgist.taoyao.signal.party.room.Room; 5 | 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | /** 10 | * 关闭数据消费者事件 11 | * 12 | * @author acgist 13 | */ 14 | @Getter 15 | @Setter 16 | public class MediaDataConsumerCloseEvent extends RoomEventAdapter { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | /** 21 | * 消费者ID 22 | */ 23 | private final String consumerId; 24 | 25 | public MediaDataConsumerCloseEvent(String consumerId, Room room) { 26 | super(room); 27 | this.consumerId = consumerId; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/event/media/MediaDataProducerCloseEvent.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.event.media; 2 | 3 | import com.acgist.taoyao.signal.event.RoomEventAdapter; 4 | import com.acgist.taoyao.signal.party.room.Room; 5 | 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | /** 10 | * 关闭数据生产者事件 11 | * 12 | * @author acgist 13 | */ 14 | @Getter 15 | @Setter 16 | public class MediaDataProducerCloseEvent extends RoomEventAdapter { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | /** 21 | * 生产者ID 22 | */ 23 | private final String producerId; 24 | 25 | public MediaDataProducerCloseEvent(String producerId, Room room) { 26 | super(room); 27 | this.producerId = producerId; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/event/media/MediaProducerCloseEvent.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.event.media; 2 | 3 | import com.acgist.taoyao.signal.event.RoomEventAdapter; 4 | import com.acgist.taoyao.signal.party.room.Room; 5 | 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | /** 10 | * 关闭生产者事件 11 | * 12 | * @author acgist 13 | */ 14 | @Getter 15 | @Setter 16 | public class MediaProducerCloseEvent extends RoomEventAdapter { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | /** 21 | * 生产者ID 22 | */ 23 | private final String producerId; 24 | 25 | public MediaProducerCloseEvent(String producerId, Room room) { 26 | super(room); 27 | this.producerId = producerId; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/event/media/MediaProducerPauseEvent.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.event.media; 2 | 3 | import com.acgist.taoyao.signal.event.RoomEventAdapter; 4 | import com.acgist.taoyao.signal.party.room.Room; 5 | 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | /** 10 | * 暂停生产者事件 11 | * 12 | * @author acgist 13 | */ 14 | @Getter 15 | @Setter 16 | public class MediaProducerPauseEvent extends RoomEventAdapter { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | /** 21 | * 生产者ID 22 | */ 23 | private final String producerId; 24 | 25 | public MediaProducerPauseEvent(String producerId, Room room) { 26 | super(room); 27 | this.producerId = producerId; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/event/media/MediaProducerResumeEvent.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.event.media; 2 | 3 | import com.acgist.taoyao.signal.event.RoomEventAdapter; 4 | import com.acgist.taoyao.signal.party.room.Room; 5 | 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | /** 10 | * 恢复生产者事件 11 | * 12 | * @author acgist 13 | */ 14 | @Getter 15 | @Setter 16 | public class MediaProducerResumeEvent extends RoomEventAdapter { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | /** 21 | * 生产者ID 22 | */ 23 | private final String producerId; 24 | 25 | public MediaProducerResumeEvent(String producerId, Room room) { 26 | super(room); 27 | this.producerId = producerId; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/event/media/TransportCloseEvent.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.event.media; 2 | 3 | import com.acgist.taoyao.signal.event.RoomEventAdapter; 4 | import com.acgist.taoyao.signal.party.room.Room; 5 | 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | /** 10 | * 关闭通道事件 11 | * 12 | * @author acgist 13 | */ 14 | @Getter 15 | @Setter 16 | public class TransportCloseEvent extends RoomEventAdapter { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | /** 21 | * 通道ID 22 | */ 23 | private final String transportId; 24 | 25 | public TransportCloseEvent(String transportId, Room room) { 26 | super(room); 27 | this.transportId = transportId; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/event/room/MediaServerRegisterEvent.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.event.room; 2 | 3 | import com.acgist.taoyao.signal.client.Client; 4 | import com.acgist.taoyao.signal.event.ClientEventAdapter; 5 | 6 | /** 7 | * 媒体服务注册事件 8 | * 需要重新创建房间 9 | * 10 | * 媒体服务掉线两种方案 11 | * 12 | * 1. 注册相同名称媒体服务,注册成功之后通知媒体服务终端重新连接。 13 | * 2. 自动转移媒体服务终端到个新的媒体服务,然后通知媒体服务终端重新连接。 14 | * 15 | * 本项目采用第一种方案 16 | * 17 | * @author acgist 18 | */ 19 | public class MediaServerRegisterEvent extends ClientEventAdapter { 20 | 21 | private static final long serialVersionUID = 1L; 22 | 23 | public MediaServerRegisterEvent(Client client) { 24 | super(client); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/event/room/RecorderCloseEvent.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.event.room; 2 | 3 | import com.acgist.taoyao.signal.event.RoomEventAdapter; 4 | import com.acgist.taoyao.signal.party.room.Recorder; 5 | 6 | import lombok.Getter; 7 | import lombok.Setter; 8 | 9 | /** 10 | * 服务端录像关闭事件 11 | * 12 | * @author acgist 13 | */ 14 | @Getter 15 | @Setter 16 | public class RecorderCloseEvent extends RoomEventAdapter { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | /** 21 | * 媒体录像机 22 | */ 23 | private final Recorder recorder; 24 | 25 | public RecorderCloseEvent(Recorder recorder) { 26 | super(recorder.getRoom()); 27 | this.recorder = recorder; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/event/room/RoomCloseEvent.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.event.room; 2 | 3 | import com.acgist.taoyao.signal.event.RoomEventAdapter; 4 | import com.acgist.taoyao.signal.party.room.Room; 5 | 6 | /** 7 | * 关闭房间事件 8 | * 9 | * @author acgist 10 | */ 11 | public class RoomCloseEvent extends RoomEventAdapter { 12 | 13 | private static final long serialVersionUID = 1L; 14 | 15 | public RoomCloseEvent(Room room) { 16 | super(room); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/event/room/RoomEnterEvent.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.event.room; 2 | 3 | import com.acgist.taoyao.signal.client.Client; 4 | import com.acgist.taoyao.signal.event.RoomEventAdapter; 5 | import com.acgist.taoyao.signal.party.room.Room; 6 | 7 | import lombok.Getter; 8 | import lombok.Setter; 9 | 10 | /** 11 | * 进入房间事件 12 | * 13 | * @author acgist 14 | */ 15 | @Getter 16 | @Setter 17 | public class RoomEnterEvent extends RoomEventAdapter { 18 | 19 | private static final long serialVersionUID = 1L; 20 | 21 | /** 22 | * 终端 23 | */ 24 | private final Client client; 25 | 26 | public RoomEnterEvent(Room room, Client client) { 27 | super(room); 28 | this.client = client; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/event/room/RoomLeaveEvent.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.event.room; 2 | 3 | import com.acgist.taoyao.signal.client.Client; 4 | import com.acgist.taoyao.signal.event.RoomEventAdapter; 5 | import com.acgist.taoyao.signal.party.room.Room; 6 | 7 | import lombok.Getter; 8 | import lombok.Setter; 9 | 10 | /** 11 | * 离开房间事件 12 | * 13 | * @author acgist 14 | */ 15 | @Getter 16 | @Setter 17 | public class RoomLeaveEvent extends RoomEventAdapter { 18 | 19 | private static final long serialVersionUID = 1L; 20 | 21 | /** 22 | * 离开终端 23 | */ 24 | private final Client client; 25 | 26 | public RoomLeaveEvent(Room room, Client client) { 27 | super(room); 28 | this.client = client; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/event/session/SessionCloseEvent.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.event.session; 2 | 3 | import com.acgist.taoyao.signal.event.SessionEventAdapter; 4 | import com.acgist.taoyao.signal.party.session.Session; 5 | 6 | /** 7 | * 关闭视频会话事件 8 | * 9 | * @author acgist 10 | */ 11 | public class SessionCloseEvent extends SessionEventAdapter { 12 | 13 | private static final long serialVersionUID = 1L; 14 | 15 | public SessionCloseEvent(Session session) { 16 | super(session); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/party/media/Kind.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.party.media; 2 | 3 | import com.acgist.taoyao.boot.model.MessageCodeException; 4 | 5 | /** 6 | * 媒体类型 7 | * 8 | * @author acgist 9 | */ 10 | public enum Kind { 11 | 12 | /** 13 | * 音频 14 | */ 15 | AUDIO, 16 | /** 17 | * 视频 18 | */ 19 | VIDEO; 20 | 21 | /** 22 | * @param value 类型 23 | * 24 | * @return 类型 25 | */ 26 | public static final Kind of(String value) { 27 | final Kind[] values = Kind.values(); 28 | for (Kind kind : values) { 29 | if(kind.name().equalsIgnoreCase(value)) { 30 | return kind; 31 | } 32 | } 33 | throw MessageCodeException.of("未知媒体类型:" + value); 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/party/media/Operator.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.party.media; 2 | 3 | import java.io.Closeable; 4 | 5 | /** 6 | * 操作接口 7 | * 8 | * @author acgist 9 | */ 10 | public interface Operator extends Closeable { 11 | 12 | /** 13 | * 关闭资源 14 | * 推荐使用事件实现 15 | */ 16 | @Override 17 | void close(); 18 | 19 | /** 20 | * 移除资源 21 | */ 22 | void remove(); 23 | 24 | /** 25 | * 暂停资源 26 | * 推荐使用事件实现 27 | */ 28 | void pause(); 29 | 30 | /** 31 | * 恢复资源 32 | * 推荐使用事件实现 33 | */ 34 | void resume(); 35 | 36 | /** 37 | * 记录日志 38 | */ 39 | void log(); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/party/media/OperatorAdapter.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.party.media; 2 | 3 | /** 4 | * 操作接口适配器 5 | * 6 | * @author acgist 7 | */ 8 | public abstract class OperatorAdapter implements Operator { 9 | 10 | /** 11 | * 是否关闭 12 | */ 13 | protected volatile boolean close = false; 14 | 15 | @Override 16 | public void close() { 17 | } 18 | 19 | @Override 20 | public void remove() { 21 | } 22 | 23 | @Override 24 | public void pause() { 25 | } 26 | 27 | @Override 28 | public void resume() { 29 | } 30 | 31 | @Override 32 | public void log() { 33 | } 34 | 35 | /** 36 | * 标记关闭 37 | * 38 | * @return 是否已经关闭 39 | */ 40 | protected boolean markClose() { 41 | synchronized (this) { 42 | final boolean old = this.close; 43 | this.close = true; 44 | return old; 45 | } 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/party/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 不同终端业务管理 3 | * 4 | * @author acgist 5 | */ 6 | package com.acgist.taoyao.signal.party; -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/party/room/RoomStatus.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.party.room; 2 | 3 | import io.swagger.v3.oas.annotations.media.Schema; 4 | import lombok.Getter; 5 | import lombok.Setter; 6 | 7 | /** 8 | * 房间状态 9 | * 10 | * @author acgist 11 | */ 12 | @Getter 13 | @Setter 14 | @Schema(title = "房间状态", description = "房间状态") 15 | public class RoomStatus { 16 | 17 | @Schema(title = "房间ID", description = "房间ID") 18 | private String roomId; 19 | @Schema(title = "房间名称", description = "房间名称") 20 | private String name; 21 | @Schema(title = "终端数量", description = "终端数量") 22 | private Long clientSize; 23 | @Schema(title = "媒体服务标识", description = "媒体服务标识") 24 | private String mediaClientId; 25 | 26 | } 27 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/party/room/RoomStatusMapstruct.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.party.room; 2 | 3 | import org.mapstruct.Mapper; 4 | import org.mapstruct.MappingConstants.ComponentModel; 5 | import org.mapstruct.MappingTarget; 6 | 7 | /** 8 | * 房间状态映射 9 | * 10 | * @author acgist 11 | */ 12 | @Mapper(componentModel = ComponentModel.SPRING) 13 | public interface RoomStatusMapstruct { 14 | 15 | /** 16 | * 对象拷贝 17 | * 18 | * @param source 原始对象 19 | * 20 | * @return 目标对象 21 | */ 22 | RoomStatus copy(RoomStatus source); 23 | 24 | /** 25 | * 对象拷贝 26 | * 27 | * @param source 原始对象 28 | * @param target 目标对象 29 | */ 30 | void copy(RoomStatus source, @MappingTarget RoomStatus target); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/party/room/SubscribeType.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.party.room; 2 | 3 | import com.acgist.taoyao.signal.party.media.Kind; 4 | import com.acgist.taoyao.signal.party.media.Producer; 5 | 6 | /** 7 | * 媒体订阅类型 8 | * 9 | * @author acgist 10 | */ 11 | public enum SubscribeType { 12 | 13 | /** 14 | * 订阅所有媒体 15 | */ 16 | ALL, 17 | /** 18 | * 订阅所有音频媒体 19 | */ 20 | ALL_AUDIO, 21 | /** 22 | * 订阅所有视频媒体 23 | */ 24 | ALL_VIDEO, 25 | /** 26 | * 没有订阅任何媒体 27 | */ 28 | NONE; 29 | 30 | /** 31 | * @param value 名称 32 | * 33 | * @return 类型 34 | */ 35 | public static final SubscribeType of(String value) { 36 | final SubscribeType[] values = SubscribeType.values(); 37 | for (SubscribeType type : values) { 38 | if(type.name().equalsIgnoreCase(value)) { 39 | return type; 40 | } 41 | } 42 | return SubscribeType.ALL; 43 | } 44 | 45 | /** 46 | * @param producer 生产者 47 | * 48 | * @return 是否可以消费 49 | */ 50 | public boolean canConsume(Producer producer) { 51 | return switch (this) { 52 | case NONE -> false; 53 | case ALL_AUDIO -> producer.getKind() == Kind.AUDIO; 54 | case ALL_VIDEO -> producer.getKind() == Kind.VIDEO; 55 | case ALL -> true; 56 | default -> true; 57 | }; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/protocol/ProtocolClientAdapter.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.protocol; 2 | 3 | import java.util.Map; 4 | 5 | import com.acgist.taoyao.boot.model.Message; 6 | import com.acgist.taoyao.signal.client.Client; 7 | import com.acgist.taoyao.signal.client.ClientType; 8 | 9 | /** 10 | * 终端信令适配器 11 | * 12 | * @author acgist 13 | */ 14 | public abstract class ProtocolClientAdapter extends ProtocolAdapter { 15 | 16 | protected ProtocolClientAdapter(String name, String signal) { 17 | super(name, signal); 18 | } 19 | 20 | @Override 21 | public void execute(Client client, Message message) { 22 | this.execute(client.getClientId(), client.getClientType(), client, message, message.body()); 23 | } 24 | 25 | /** 26 | * 处理终端信令 27 | * 28 | * @param clientId 终端ID 29 | * @param clientType 终端类型 30 | * @param client 终端 31 | * @param message 信令消息 32 | * @param body 消息主体 33 | */ 34 | public void execute(String clientId, ClientType clientType, Client client, Message message, Map body) { 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/protocol/client/ClientRebootProtocol.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.protocol.client; 2 | 3 | import com.acgist.taoyao.boot.annotation.Description; 4 | import com.acgist.taoyao.boot.annotation.Protocol; 5 | import com.acgist.taoyao.signal.protocol.ProtocolClientAdapter; 6 | 7 | /** 8 | * 重启终端信令 9 | * 10 | * @author acgist 11 | */ 12 | @Protocol 13 | @Description( 14 | flow = "信令服务->终端" 15 | ) 16 | public class ClientRebootProtocol extends ProtocolClientAdapter { 17 | 18 | public static final String SIGNAL = "client::reboot"; 19 | 20 | public ClientRebootProtocol() { 21 | super("重启终端信令", SIGNAL); 22 | } 23 | 24 | /** 25 | * @param clientId 终端ID 26 | */ 27 | public void execute(String clientId) { 28 | this.clientManager.unicast(clientId, this.build()); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/protocol/client/ClientShutdownProtocol.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.protocol.client; 2 | 3 | import com.acgist.taoyao.boot.annotation.Description; 4 | import com.acgist.taoyao.boot.annotation.Protocol; 5 | import com.acgist.taoyao.signal.protocol.ProtocolClientAdapter; 6 | 7 | /** 8 | * 关闭终端信令 9 | * 10 | * @author acgist 11 | */ 12 | @Protocol 13 | @Description( 14 | flow = "信令服务->终端" 15 | ) 16 | public class ClientShutdownProtocol extends ProtocolClientAdapter { 17 | 18 | public static final String SIGNAL = "client::shutdown"; 19 | 20 | public ClientShutdownProtocol() { 21 | super("关闭终端信令", SIGNAL); 22 | } 23 | 24 | /** 25 | * @param clientId 终端ID 26 | */ 27 | public void execute(String clientId) { 28 | this.clientManager.unicast(clientId, this.build()); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/protocol/client/ClientUnicastProtocol.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.protocol.client; 2 | 3 | import java.util.Map; 4 | 5 | import com.acgist.taoyao.boot.annotation.Description; 6 | import com.acgist.taoyao.boot.annotation.Protocol; 7 | import com.acgist.taoyao.boot.config.Constant; 8 | import com.acgist.taoyao.boot.model.Message; 9 | import com.acgist.taoyao.boot.utils.MapUtils; 10 | import com.acgist.taoyao.signal.client.Client; 11 | import com.acgist.taoyao.signal.client.ClientType; 12 | import com.acgist.taoyao.signal.protocol.ProtocolClientAdapter; 13 | 14 | /** 15 | * 终端单播信令 16 | * 17 | * @author acgist 18 | */ 19 | @Protocol 20 | @Description( 21 | body = { 22 | """ 23 | { 24 | "to": "接收终端ID", 25 | ... 26 | } 27 | """, 28 | """ 29 | { 30 | ... 31 | } 32 | """ 33 | }, 34 | flow = "终端->信令服务->终端" 35 | ) 36 | public class ClientUnicastProtocol extends ProtocolClientAdapter { 37 | 38 | public static final String SIGNAL = "client::unicast"; 39 | 40 | public ClientUnicastProtocol() { 41 | super("终端单播信令", SIGNAL); 42 | } 43 | 44 | @Override 45 | public void execute(String clientId, ClientType clientType, Client client, Message message, Map body) { 46 | final String to = MapUtils.remove(body, Constant.TO); 47 | this.clientManager.unicast(to, message); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/protocol/control/IControlBellProtocol.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.protocol.control; 2 | 3 | import com.acgist.taoyao.boot.model.Message; 4 | 5 | /** 6 | * 响铃信令接口 7 | * 8 | * @author acgist 9 | */ 10 | public interface IControlBellProtocol { 11 | 12 | /** 13 | * @param clientId 终端ID 14 | * @param enabled 状态 15 | * 16 | * @return 执行结果 17 | */ 18 | Message execute(String clientId, Boolean enabled); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/protocol/control/IControlClientRecordProtocol.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.protocol.control; 2 | 3 | import com.acgist.taoyao.boot.model.Message; 4 | 5 | /** 6 | * 终端录像信令接口 7 | * 8 | * @author acgist 9 | */ 10 | public interface IControlClientRecordProtocol { 11 | 12 | /** 13 | * @param clientId 终端ID 14 | * @param enabled 状态 15 | * 16 | * @return 执行结果 17 | */ 18 | Message execute(String clientId, Boolean enabled); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/protocol/control/IControlConfigAudioProtocol.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.protocol.control; 2 | 3 | import com.acgist.taoyao.boot.config.MediaAudioProperties; 4 | import com.acgist.taoyao.boot.model.Message; 5 | 6 | /** 7 | * 配置音频信令 8 | * 9 | * @author acgist 10 | */ 11 | public interface IControlConfigAudioProtocol { 12 | 13 | /** 14 | * @param clientId 终端ID 15 | * @param mediaAudioProperties 音频配置 16 | * 17 | * @return 执行结果 18 | */ 19 | Message execute(String clientId, MediaAudioProperties mediaAudioProperties); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/protocol/control/IControlConfigVideoProtocol.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.protocol.control; 2 | 3 | import com.acgist.taoyao.boot.config.MediaVideoProperties; 4 | import com.acgist.taoyao.boot.model.Message; 5 | 6 | /** 7 | * 配置视频信令接口 8 | * 9 | * @author acgist 10 | */ 11 | public interface IControlConfigVideoProtocol { 12 | 13 | /** 14 | * @param clientId 终端ID 15 | * @param mediaVideoProperties 视频配置 16 | * 17 | * @return 执行结果 18 | */ 19 | Message execute(String clientId, MediaVideoProperties mediaVideoProperties); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/protocol/control/IControlPhotographProtocol.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.protocol.control; 2 | 3 | import com.acgist.taoyao.boot.model.Message; 4 | 5 | /** 6 | * 拍照信令接口 7 | * 8 | * @author acgist 9 | */ 10 | public interface IControlPhotographProtocol { 11 | 12 | /** 13 | * @param clientId 终端标识 14 | * 15 | * @return 执行结果 16 | */ 17 | Message execute(String clientId); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/protocol/control/IControlServerRecordProtocol.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.protocol.control; 2 | 3 | import com.acgist.taoyao.boot.model.Message; 4 | 5 | /** 6 | * 服务端录像信令接口 7 | * 8 | * @author acgist 9 | */ 10 | public interface IControlServerRecordProtocol { 11 | 12 | /** 13 | * @param roomId 房间ID 14 | * @param clientId 终端ID 15 | * @param enabled 状态 16 | * 17 | * @return 执行结果 18 | */ 19 | Message execute(String roomId, String clientId, Boolean enabled); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/protocol/control/IControlWakeupProtocol.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.protocol.control; 2 | 3 | import com.acgist.taoyao.boot.model.Message; 4 | 5 | /** 6 | * 终端唤醒信令接口 7 | * 8 | * @author acgist 9 | */ 10 | public interface IControlWakeupProtocol { 11 | 12 | /** 13 | * @param clientId 终端ID 14 | * 15 | * @return 执行结果 16 | */ 17 | Message execute(String clientId); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/protocol/room/RoomBroadcastProtocol.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.protocol.room; 2 | 3 | import java.util.Map; 4 | 5 | import com.acgist.taoyao.boot.annotation.Description; 6 | import com.acgist.taoyao.boot.annotation.Protocol; 7 | import com.acgist.taoyao.boot.model.Message; 8 | import com.acgist.taoyao.signal.client.Client; 9 | import com.acgist.taoyao.signal.client.ClientType; 10 | import com.acgist.taoyao.signal.party.room.Room; 11 | import com.acgist.taoyao.signal.protocol.ProtocolRoomAdapter; 12 | 13 | /** 14 | * 房间广播信令 15 | * 16 | * @author acgist 17 | */ 18 | @Protocol 19 | @Description( 20 | body = """ 21 | { 22 | "roomId": "房间ID", 23 | ... 24 | } 25 | """, 26 | flow = "终端->信令服务-)终端" 27 | ) 28 | public class RoomBroadcastProtocol extends ProtocolRoomAdapter { 29 | 30 | public static final String SIGNAL = "room::broadcast"; 31 | 32 | public RoomBroadcastProtocol() { 33 | super("房间广播信令", SIGNAL); 34 | } 35 | 36 | @Override 37 | public void execute(String clientId, ClientType clientType, Room room, Client client, Client mediaClient, Message message, Map body) { 38 | room.broadcast(client, message); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/protocol/session/SessionPauseProtocol.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.protocol.session; 2 | 3 | import java.util.Map; 4 | 5 | import com.acgist.taoyao.boot.annotation.Description; 6 | import com.acgist.taoyao.boot.annotation.Protocol; 7 | import com.acgist.taoyao.boot.model.Message; 8 | import com.acgist.taoyao.signal.client.Client; 9 | import com.acgist.taoyao.signal.client.ClientType; 10 | import com.acgist.taoyao.signal.party.session.Session; 11 | import com.acgist.taoyao.signal.protocol.ProtocolSessionAdapter; 12 | 13 | /** 14 | * 暂停媒体信令 15 | * 16 | * @author acgist 17 | */ 18 | @Protocol 19 | @Description( 20 | body = """ 21 | { 22 | "sessionId": "会话ID", 23 | "type" : "媒体类型(audio|voice)" 24 | } 25 | """, 26 | flow = "终端->信令服务->终端" 27 | ) 28 | public class SessionPauseProtocol extends ProtocolSessionAdapter { 29 | 30 | public static final String SIGNAL = "session::pause"; 31 | 32 | public SessionPauseProtocol() { 33 | super("暂停媒体信令", SIGNAL); 34 | } 35 | 36 | @Override 37 | public void execute(String clientId, ClientType clientType, Session session, Client client, Message message, Map body) { 38 | session.pushRemote(clientId, message); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/protocol/session/SessionResumeProtocol.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.protocol.session; 2 | 3 | import java.util.Map; 4 | 5 | import com.acgist.taoyao.boot.annotation.Description; 6 | import com.acgist.taoyao.boot.annotation.Protocol; 7 | import com.acgist.taoyao.boot.model.Message; 8 | import com.acgist.taoyao.signal.client.Client; 9 | import com.acgist.taoyao.signal.client.ClientType; 10 | import com.acgist.taoyao.signal.party.session.Session; 11 | import com.acgist.taoyao.signal.protocol.ProtocolSessionAdapter; 12 | 13 | /** 14 | * 恢复媒体信令 15 | * 16 | * @author acgist 17 | */ 18 | @Protocol 19 | @Description( 20 | body = """ 21 | { 22 | "sessionId": "会话ID", 23 | "type" : "媒体类型(audio|voice)" 24 | } 25 | """, 26 | flow = "终端->信令服务->终端" 27 | ) 28 | public class SessionResumeProtocol extends ProtocolSessionAdapter { 29 | 30 | public static final String SIGNAL = "session::resume"; 31 | 32 | public SessionResumeProtocol() { 33 | super("恢复媒体信令", SIGNAL); 34 | } 35 | 36 | @Override 37 | public void execute(String clientId, ClientType clientType, Session session, Client client, Message message, Map body) { 38 | session.pushRemote(clientId, message); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/service/SecurityService.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.service; 2 | 3 | import com.acgist.taoyao.boot.model.Message; 4 | import com.acgist.taoyao.signal.client.Client; 5 | import com.acgist.taoyao.signal.protocol.Protocol; 6 | 7 | /** 8 | * 信令安全 9 | * 10 | * @author acgist 11 | */ 12 | public interface SecurityService { 13 | 14 | /** 15 | * 认证 16 | * 17 | * @param username 用户名称 18 | * @param password 用户密码 19 | * 20 | * @return 是否成功 21 | * 22 | * @see UsernamePasswordService 23 | */ 24 | boolean authenticate(String username, String password); 25 | 26 | /** 27 | * 鉴权 28 | * 29 | * @param client 终端 30 | * @param message 信令消息 31 | * @param protocol 协议 32 | * 33 | * @return 是否成功 34 | */ 35 | boolean authenticate(Client client, Message message, Protocol protocol); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/java/com/acgist/taoyao/signal/service/UsernamePasswordService.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.service; 2 | 3 | /** 4 | * 帐号密码认证服务 5 | * 6 | * 用于验证帐号密码,如果没有提供实现默认使用配置中的帐号密码。 7 | * 8 | * @author acgist 9 | */ 10 | public interface UsernamePasswordService { 11 | 12 | /** 13 | * 帐号密码认证 14 | * 15 | * @param username 帐号 16 | * @param password 密码 17 | * 18 | * @return 是否成功 19 | */ 20 | boolean authenticate(String username, String password); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports: -------------------------------------------------------------------------------- 1 | com.acgist.taoyao.signal.configuration.ScriptAutoConfiguration 2 | com.acgist.taoyao.signal.configuration.SignalAutoConfiguration 3 | com.acgist.taoyao.signal.configuration.SocketSignalAutoConfiguration 4 | com.acgist.taoyao.signal.configuration.WebSocketSignalAutoConfiguration -------------------------------------------------------------------------------- /taoyao-signal-server/taoyao-signal/src/test/java/com/acgist/taoyao/signal/utils/CipherUtilsTest.java: -------------------------------------------------------------------------------- 1 | package com.acgist.taoyao.signal.utils; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertNotNull; 4 | import static org.junit.jupiter.api.Assertions.assertNull; 5 | 6 | import javax.crypto.Cipher; 7 | 8 | import org.junit.jupiter.api.Test; 9 | 10 | import com.acgist.taoyao.boot.config.SocketProperties.Encrypt; 11 | 12 | public class CipherUtilsTest { 13 | 14 | @Test 15 | public void testBuildCipher() { 16 | final String secret = "2SPWy+TF1zM=".strip(); 17 | assertNull(CipherUtils.buildCipher(Cipher.ENCRYPT_MODE, Encrypt.PLAINTEXT, secret)); 18 | assertNull(CipherUtils.buildCipher(Cipher.ENCRYPT_MODE, Encrypt.DES, null)); 19 | assertNotNull(CipherUtils.buildCipher(Cipher.ENCRYPT_MODE, Encrypt.DES, secret)); 20 | } 21 | 22 | } 23 | --------------------------------------------------------------------------------