├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── styles.xml │ │ │ │ └── colors.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ └── ic_launcher_round.png │ │ │ ├── drawable │ │ │ │ ├── trans_bg.xml │ │ │ │ ├── bg_list_blue.xml │ │ │ │ ├── bg_blue_border_select.xml │ │ │ │ ├── bg_player_control.xml │ │ │ │ └── bg_tv_list_selector.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── layout │ │ │ │ ├── activity_full_screen.xml │ │ │ │ ├── activity_web.xml │ │ │ │ ├── item_tvprogram.xml │ │ │ │ └── activity_main.xml │ │ │ └── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ ├── java │ │ │ └── com │ │ │ │ └── td │ │ │ │ └── exoplayerdemo │ │ │ │ ├── base │ │ │ │ └── BaseApplication.java │ │ │ │ ├── WebActivity.java │ │ │ │ └── adapter │ │ │ │ └── TVListAdapter.java │ │ ├── assets │ │ │ └── index.html │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── td │ │ │ └── exoplayerdemo │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── td │ │ └── exoplayerdemo │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── connectlib ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ └── values │ │ │ │ └── strings.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ ├── org │ │ │ ├── java_ws │ │ │ │ ├── enums │ │ │ │ │ ├── Role.java │ │ │ │ │ ├── ReadyState.java │ │ │ │ │ ├── CloseHandshakeType.java │ │ │ │ │ ├── Opcode.java │ │ │ │ │ ├── HandshakeState.java │ │ │ │ │ └── package-info.java │ │ │ │ ├── exceptions │ │ │ │ │ ├── InvalidEncodingException.java │ │ │ │ │ ├── package-info.java │ │ │ │ │ ├── WebsocketNotConnectedException.java │ │ │ │ │ ├── IncompleteException.java │ │ │ │ │ ├── NotSendableException.java │ │ │ │ │ └── IncompleteHandshakeException.java │ │ │ │ ├── util │ │ │ │ │ ├── package-info.java │ │ │ │ │ └── ByteBufferUtils.java │ │ │ │ ├── client │ │ │ │ │ └── package-info.java │ │ │ │ ├── drafts │ │ │ │ │ └── package-info.java │ │ │ │ ├── server │ │ │ │ │ ├── package-info.java │ │ │ │ │ └── DefaultWebSocketServerFactory.java │ │ │ │ ├── framing │ │ │ │ │ ├── package-info.java │ │ │ │ │ ├── PingFrame.java │ │ │ │ │ ├── BinaryFrame.java │ │ │ │ │ ├── ContinuousFrame.java │ │ │ │ │ ├── DataFrame.java │ │ │ │ │ ├── PongFrame.java │ │ │ │ │ ├── TextFrame.java │ │ │ │ │ └── ControlFrame.java │ │ │ │ ├── handshake │ │ │ │ │ ├── package-info.java │ │ │ │ │ ├── ClientHandshake.java │ │ │ │ │ ├── ClientHandshakeBuilder.java │ │ │ │ │ ├── ServerHandshake.java │ │ │ │ │ ├── HandshakeBuilder.java │ │ │ │ │ ├── ServerHandshakeBuilder.java │ │ │ │ │ ├── HandshakeImpl1Client.java │ │ │ │ │ ├── HandshakeImpl1Server.java │ │ │ │ │ ├── Handshakedata.java │ │ │ │ │ └── HandshakedataImpl1.java │ │ │ │ ├── extensions │ │ │ │ │ ├── package-info.java │ │ │ │ │ └── CompressionExtension.java │ │ │ │ ├── protocols │ │ │ │ │ └── package-info.java │ │ │ │ ├── WebSocketFactory.java │ │ │ │ ├── WebSocketServerFactory.java │ │ │ │ └── WrappedByteChannel.java │ │ │ └── java_websocket │ │ │ │ ├── enums │ │ │ │ ├── Role.java │ │ │ │ ├── ReadyState.java │ │ │ │ ├── CloseHandshakeType.java │ │ │ │ ├── Opcode.java │ │ │ │ ├── HandshakeState.java │ │ │ │ └── package-info.java │ │ │ │ ├── exceptions │ │ │ │ ├── InvalidEncodingException.java │ │ │ │ ├── package-info.java │ │ │ │ ├── WebsocketNotConnectedException.java │ │ │ │ ├── IncompleteException.java │ │ │ │ ├── NotSendableException.java │ │ │ │ └── IncompleteHandshakeException.java │ │ │ │ ├── util │ │ │ │ ├── package-info.java │ │ │ │ └── ByteBufferUtils.java │ │ │ │ ├── client │ │ │ │ └── package-info.java │ │ │ │ ├── drafts │ │ │ │ └── package-info.java │ │ │ │ ├── server │ │ │ │ ├── package-info.java │ │ │ │ └── DefaultWebSocketServerFactory.java │ │ │ │ ├── framing │ │ │ │ ├── package-info.java │ │ │ │ ├── PingFrame.java │ │ │ │ ├── BinaryFrame.java │ │ │ │ ├── ContinuousFrame.java │ │ │ │ ├── DataFrame.java │ │ │ │ ├── PongFrame.java │ │ │ │ ├── TextFrame.java │ │ │ │ └── ControlFrame.java │ │ │ │ ├── handshake │ │ │ │ ├── package-info.java │ │ │ │ ├── ClientHandshake.java │ │ │ │ ├── ClientHandshakeBuilder.java │ │ │ │ ├── ServerHandshake.java │ │ │ │ ├── HandshakeBuilder.java │ │ │ │ ├── ServerHandshakeBuilder.java │ │ │ │ ├── HandshakeImpl1Client.java │ │ │ │ ├── HandshakeImpl1Server.java │ │ │ │ ├── Handshakedata.java │ │ │ │ └── HandshakedataImpl1.java │ │ │ │ ├── protocols │ │ │ │ └── package-info.java │ │ │ │ ├── extensions │ │ │ │ ├── package-info.java │ │ │ │ └── CompressionExtension.java │ │ │ │ ├── WebSocketFactory.java │ │ │ │ └── WebSocketServerFactory.java │ │ │ └── com │ │ │ └── google │ │ │ └── connectlib │ │ │ ├── Constants.java │ │ │ ├── Utils.java │ │ │ ├── EmptyClient.java │ │ │ └── ConnectService.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── google │ │ │ └── connectlib │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── google │ │ └── connectlib │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── exoplayer ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── drawable │ │ │ │ ├── icon_mute.png │ │ │ │ ├── icon_pause.png │ │ │ │ ├── icon_play.png │ │ │ │ ├── loading_bg.jpg │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── icon_volume.png │ │ │ │ ├── video_forward_icon.png │ │ │ │ ├── video_volume_icon.png │ │ │ │ ├── video_backward_icon.png │ │ │ │ ├── video_brightness_6_white_36dp.png │ │ │ │ ├── volume_seek_thumb_normal.xml │ │ │ │ ├── bg_player_top.xml │ │ │ │ ├── bg_tips.xml │ │ │ │ ├── video_dialog_progress_bg.xml │ │ │ │ ├── bg_play_btn.xml │ │ │ │ ├── video_seek_progress.xml │ │ │ │ ├── video_seek_progress_bg.xml │ │ │ │ └── progressbar.xml │ │ │ ├── layout │ │ │ │ ├── exo_player_view.xml │ │ │ │ ├── exo_player_control_view.xml │ │ │ │ ├── start_download_dialog.xml │ │ │ │ ├── layout_volumn_toast.xml │ │ │ │ ├── layout_exoplayer_top.xml │ │ │ │ └── layout_touchcontrollview.xml │ │ │ └── values │ │ │ │ ├── colors.xml │ │ │ │ ├── styles.xml │ │ │ │ └── strings.xml │ │ ├── jniLibs │ │ │ ├── arm64-v8a │ │ │ │ ├── libavutil.so │ │ │ │ ├── libffmpeg.so │ │ │ │ ├── libavcodec.so │ │ │ │ └── libavresample.so │ │ │ └── armeabi-v7a │ │ │ │ ├── libavutil.so │ │ │ │ ├── libffmpeg.so │ │ │ │ ├── libavcodec.so │ │ │ │ └── libavresample.so │ │ ├── java │ │ │ └── com │ │ │ │ ├── td │ │ │ │ └── exoplayer │ │ │ │ │ ├── utils │ │ │ │ │ ├── SettingIml.java │ │ │ │ │ └── SettingReceiver.java │ │ │ │ │ └── FFMPEGRenderFactory.java │ │ │ │ └── google │ │ │ │ └── android │ │ │ │ └── exoplayer2 │ │ │ │ └── ext │ │ │ │ └── ffmpeg │ │ │ │ └── FfmpegDecoderException.java │ │ ├── AndroidManifest.xml │ │ └── assets │ │ │ └── simple.json │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── td │ │ │ └── exoplayer │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── td │ │ └── exoplayer │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── .gitattributes ├── exoplayer-release.aar ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── wsserver.js ├── README.md ├── LICENSE ├── .gitignore └── index.html /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /connectlib/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /exoplayer/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app',':exoplayer', ':connectlib' 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /exoplayer-release.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/exoplayer-release.aar -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ExoPlayerDemo 3 | 4 | -------------------------------------------------------------------------------- /connectlib/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | connectLib 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /exoplayer/src/main/res/drawable/icon_mute.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/exoplayer/src/main/res/drawable/icon_mute.png -------------------------------------------------------------------------------- /exoplayer/src/main/res/drawable/icon_pause.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/exoplayer/src/main/res/drawable/icon_pause.png -------------------------------------------------------------------------------- /exoplayer/src/main/res/drawable/icon_play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/exoplayer/src/main/res/drawable/icon_play.png -------------------------------------------------------------------------------- /exoplayer/src/main/res/drawable/loading_bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/exoplayer/src/main/res/drawable/loading_bg.jpg -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /connectlib/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /exoplayer/src/main/jniLibs/arm64-v8a/libavutil.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/exoplayer/src/main/jniLibs/arm64-v8a/libavutil.so -------------------------------------------------------------------------------- /exoplayer/src/main/jniLibs/arm64-v8a/libffmpeg.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/exoplayer/src/main/jniLibs/arm64-v8a/libffmpeg.so -------------------------------------------------------------------------------- /exoplayer/src/main/res/drawable/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/exoplayer/src/main/res/drawable/ic_launcher.png -------------------------------------------------------------------------------- /exoplayer/src/main/res/drawable/icon_volume.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/exoplayer/src/main/res/drawable/icon_volume.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /exoplayer/src/main/jniLibs/arm64-v8a/libavcodec.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/exoplayer/src/main/jniLibs/arm64-v8a/libavcodec.so -------------------------------------------------------------------------------- /exoplayer/src/main/jniLibs/armeabi-v7a/libavutil.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/exoplayer/src/main/jniLibs/armeabi-v7a/libavutil.so -------------------------------------------------------------------------------- /exoplayer/src/main/jniLibs/armeabi-v7a/libffmpeg.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/exoplayer/src/main/jniLibs/armeabi-v7a/libffmpeg.so -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /exoplayer/src/main/jniLibs/arm64-v8a/libavresample.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/exoplayer/src/main/jniLibs/arm64-v8a/libavresample.so -------------------------------------------------------------------------------- /exoplayer/src/main/jniLibs/armeabi-v7a/libavcodec.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/exoplayer/src/main/jniLibs/armeabi-v7a/libavcodec.so -------------------------------------------------------------------------------- /exoplayer/src/main/res/drawable/video_forward_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/exoplayer/src/main/res/drawable/video_forward_icon.png -------------------------------------------------------------------------------- /exoplayer/src/main/res/drawable/video_volume_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/exoplayer/src/main/res/drawable/video_volume_icon.png -------------------------------------------------------------------------------- /exoplayer/src/main/jniLibs/armeabi-v7a/libavresample.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/exoplayer/src/main/jniLibs/armeabi-v7a/libavresample.so -------------------------------------------------------------------------------- /exoplayer/src/main/res/drawable/video_backward_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/exoplayer/src/main/res/drawable/video_backward_icon.png -------------------------------------------------------------------------------- /exoplayer/src/main/res/layout/exo_player_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /exoplayer/src/main/res/layout/exo_player_control_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /exoplayer/src/main/res/drawable/video_brightness_6_white_36dp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jaychou2012/TV_ExoPlayer/HEAD/exoplayer/src/main/res/drawable/video_brightness_6_white_36dp.png -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/enums/Role.java: -------------------------------------------------------------------------------- 1 | package org.java_ws.enums; 2 | 3 | /** 4 | * Enum which represents the states a websocket may be in 5 | */ 6 | public enum Role { 7 | CLIENT, SERVER 8 | } -------------------------------------------------------------------------------- /app/src/main/res/drawable/trans_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /exoplayer/src/main/java/com/td/exoplayer/utils/SettingIml.java: -------------------------------------------------------------------------------- 1 | package com.td.exoplayer.utils; 2 | 3 | import android.content.Intent; 4 | 5 | public interface SettingIml { 6 | void onAction(Intent intent); 7 | } 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_list_blue.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/enums/Role.java: -------------------------------------------------------------------------------- 1 | package org.java_websocket.enums; 2 | 3 | /** 4 | * Enum which represents the states a websocket may be in 5 | */ 6 | public enum Role { 7 | CLIENT, SERVER 8 | } -------------------------------------------------------------------------------- /connectlib/src/main/java/com/google/connectlib/Constants.java: -------------------------------------------------------------------------------- 1 | package com.google.connectlib; 2 | 3 | public class Constants { 4 | public static String HOST = Utils.getLocalIpV4Address(); 5 | public static int PORT = 8887; 6 | } 7 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/enums/ReadyState.java: -------------------------------------------------------------------------------- 1 | package org.java_ws.enums; 2 | 3 | /** 4 | * Enum which represents the state a websocket may be in 5 | */ 6 | public enum ReadyState { 7 | NOT_YET_CONNECTED, OPEN, CLOSING, CLOSED 8 | } -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/enums/CloseHandshakeType.java: -------------------------------------------------------------------------------- 1 | package org.java_ws.enums; 2 | 3 | /** 4 | * Enum which represents type of handshake is required for a close 5 | */ 6 | public enum CloseHandshakeType { 7 | NONE, ONEWAY, TWOWAY 8 | } -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/enums/ReadyState.java: -------------------------------------------------------------------------------- 1 | package org.java_websocket.enums; 2 | 3 | /** 4 | * Enum which represents the state a websocket may be in 5 | */ 6 | public enum ReadyState { 7 | NOT_YET_CONNECTED, OPEN, CLOSING, CLOSED 8 | } -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/enums/Opcode.java: -------------------------------------------------------------------------------- 1 | package org.java_ws.enums; 2 | 3 | /** 4 | * Enum which contains the different valid opcodes 5 | */ 6 | public enum Opcode { 7 | CONTINUOUS, TEXT, BINARY, PING, PONG, CLOSING 8 | // more to come 9 | } -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/enums/CloseHandshakeType.java: -------------------------------------------------------------------------------- 1 | package org.java_websocket.enums; 2 | 3 | /** 4 | * Enum which represents type of handshake is required for a close 5 | */ 6 | public enum CloseHandshakeType { 7 | NONE, ONEWAY, TWOWAY 8 | } -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/enums/Opcode.java: -------------------------------------------------------------------------------- 1 | package org.java_websocket.enums; 2 | 3 | /** 4 | * Enum which contains the different valid opcodes 5 | */ 6 | public enum Opcode { 7 | CONTINUOUS, TEXT, BINARY, PING, PONG, CLOSING 8 | // more to come 9 | } -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon May 13 10:02:15 CST 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /exoplayer/src/main/res/drawable/volume_seek_thumb_normal.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_blue_border_select.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_player_control.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/bg_tv_list_selector.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/enums/HandshakeState.java: -------------------------------------------------------------------------------- 1 | package org.java_ws.enums; 2 | 3 | /** 4 | * Enum which represents the states a handshake may be in 5 | */ 6 | public enum HandshakeState { 7 | /** Handshake matched this Draft successfully */ 8 | MATCHED, 9 | /** Handshake is does not match this Draft */ 10 | NOT_MATCHED 11 | } -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/enums/HandshakeState.java: -------------------------------------------------------------------------------- 1 | package org.java_websocket.enums; 2 | 3 | /** 4 | * Enum which represents the states a handshake may be in 5 | */ 6 | public enum HandshakeState { 7 | /** Handshake matched this Draft successfully */ 8 | MATCHED, 9 | /** Handshake is does not match this Draft */ 10 | NOT_MATCHED 11 | } -------------------------------------------------------------------------------- /exoplayer/src/main/res/drawable/bg_player_top.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | -------------------------------------------------------------------------------- /exoplayer/src/main/res/drawable/bg_tips.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /exoplayer/src/main/res/drawable/video_dialog_progress_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_full_screen.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /exoplayer/src/main/res/drawable/bg_play_btn.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 10 | 13 | -------------------------------------------------------------------------------- /exoplayer/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #000000 4 | #00000000 5 | #80000000 6 | #D0000000 7 | #FFFFFF 8 | #6c6c6c 9 | #B011ADFF 10 | #178fff 11 | -------------------------------------------------------------------------------- /app/src/test/java/com/td/exoplayerdemo/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.td.exoplayerdemo; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /exoplayer/src/test/java/com/td/exoplayer/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.td.exoplayer; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /connectlib/src/test/java/com/google/connectlib/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.google.connectlib; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_web.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /exoplayer/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | #000000 7 | #00000000 8 | #80000000 9 | #D0000000 10 | #FFFFFF 11 | #6c6c6c 12 | #B011ADFF 13 | #178fff 14 | 15 | -------------------------------------------------------------------------------- /exoplayer/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /wsserver.js: -------------------------------------------------------------------------------- 1 | // const WebSocket = require('ws'); 2 | 3 | // const wss = new WebSocket.Server({ port: 8080 }); 4 | 5 | // wss.on('connection', function connection(ws) { 6 | // ws.on('message', function incoming(message) { 7 | // console.log('received: %s', message); 8 | // }); 9 | 10 | // ws.send('something'); 11 | // }); 12 | 13 | var ws = require("nodejs-websocket") 14 | 15 | // Scream server example: "hi" -> "HI!!!" 16 | var server = ws.createServer(function(conn) { 17 | console.log("New connection") 18 | conn.on("text", function(str) { 19 | console.log("Received " + str) 20 | conn.sendText(str.toUpperCase() + "!!!") 21 | }) 22 | conn.on("close", function(code, reason) { 23 | console.log("Connection closed") 24 | }) 25 | }).listen(8001) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TV_ExoPlayer 2 | 3 | 基于最新版ExoPlayer修改的TV版本的播放器,扩展了FFMPEG模块,支持更多音视频格式。 4 | 5 | 非常稳定,支持遥控器快进快退。支持自定义片头广告:视频广告、图片广告(Gif、静态图片均支持)等功能,已经适配手机播放,手机操作的其他功能自己可以修改扩展。 6 | 7 | 持续完善更新中... 8 | 9 | 10 | ## 《Android开发进阶实战:拓展与提升》已出版 11 | 12 | 13 | ### 新书涵盖Android最新的技术和内容,包括:新布局方式ConstraintLayout 、AndroidX、Jetpack、TV开发等,值得购买阅读。 14 | 15 | 16 | ![Android开发进阶实战:拓展与提升](http://img13.360buyimg.com/n1/jfs/t1/113550/10/7905/112523/5ec79791E6bf5d507/7169944c4d0d6669.jpg "Android开发进阶实战:拓展与提升") 17 | 18 | 19 | ### 纸质书购买: 20 | 21 | [京东](https://item.jd.com/69496918930.html "京东") [天猫](https://detail.tmall.com/item.htm?spm=a220m.1000858.1000725.6.7103434dRkHC8S&id=618745314823&user_id=3446196188&cat_id=2&is_b=1&rn=45bd1618b102199a8f9794a7b8431df4 "天猫") [当当](http://product.dangdang.com/28552590.html "当当") 22 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /connectlib/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /exoplayer/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /exoplayer/src/androidTest/java/com/td/exoplayer/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.td.exoplayer; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("cn.cbg.exoplayer.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/td/exoplayerdemo/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.td.exoplayerdemo; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("cn.cbg.exoplayerdemo", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/td/exoplayerdemo/base/BaseApplication.java: -------------------------------------------------------------------------------- 1 | package com.td.exoplayerdemo.base; 2 | 3 | import android.app.Application; 4 | import android.content.Context; 5 | import android.support.multidex.MultiDex; 6 | 7 | import com.google.android.exoplayer2.Player; 8 | 9 | import com.td.exoplayerdemo.utils.CrashHandler; 10 | 11 | public class BaseApplication extends Application { 12 | public static Player player; 13 | 14 | @Override 15 | protected void attachBaseContext(Context base) { 16 | super.attachBaseContext(base); 17 | MultiDex.install(base); 18 | } 19 | 20 | @Override 21 | public void onCreate() { 22 | super.onCreate(); 23 | initcrash(); 24 | } 25 | 26 | private void initcrash() { 27 | CrashHandler crashHandler = CrashHandler.getInstance(); 28 | crashHandler.init(getApplicationContext()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /connectlib/src/androidTest/java/com/google/connectlib/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.google.connectlib; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumented test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.google.connectlib.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /connectlib/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 28 5 | 6 | 7 | defaultConfig { 8 | minSdkVersion 15 9 | targetSdkVersion 28 10 | versionCode 1 11 | versionName "1.0" 12 | 13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 14 | 15 | } 16 | 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | 24 | } 25 | 26 | dependencies { 27 | implementation fileTree(dir: 'libs', include: ['*.jar']) 28 | implementation 'com.android.support:appcompat-v7:28.0.0' 29 | testImplementation 'junit:junit:4.12' 30 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 31 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 32 | } 33 | -------------------------------------------------------------------------------- /exoplayer/src/main/res/layout/start_download_dialog.xml: -------------------------------------------------------------------------------- 1 | 15 | 19 | -------------------------------------------------------------------------------- /exoplayer/src/main/res/drawable/video_seek_progress.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /exoplayer/src/main/res/drawable/video_seek_progress_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /exoplayer/src/main/java/com/td/exoplayer/utils/SettingReceiver.java: -------------------------------------------------------------------------------- 1 | package com.td.exoplayer.utils; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.net.ConnectivityManager; 7 | 8 | /** 9 | * Created by office on 2018/5/9. 10 | */ 11 | 12 | public class SettingReceiver extends BroadcastReceiver { 13 | private static final String ACTION_BOOT = "BOOT_COMPLETE_ACTION";//Intent.ACTION_BOOT_COMPLETED 14 | private static final String ACTION_CONNECT_CHANGE = ConnectivityManager.CONNECTIVITY_ACTION; 15 | private SettingIml settingIml; 16 | 17 | public SettingReceiver(SettingIml iml) { 18 | this.settingIml = iml; 19 | } 20 | 21 | @Override 22 | public void onReceive(Context context, Intent intent) { 23 | if (intent.getAction().equals(Intent.ACTION_BOOT_COMPLETED)) { 24 | 25 | } else if (intent.getAction().equals(ACTION_CONNECT_CHANGE)) { 26 | 27 | } 28 | if (settingIml != null) { 29 | settingIml.onAction(intent); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /connectlib/src/main/java/com/google/connectlib/Utils.java: -------------------------------------------------------------------------------- 1 | package com.google.connectlib; 2 | 3 | import android.util.Log; 4 | 5 | import java.net.InetAddress; 6 | import java.net.NetworkInterface; 7 | import java.net.SocketException; 8 | import java.util.ArrayList; 9 | import java.util.Collections; 10 | 11 | public class Utils { 12 | public static String getLocalIpV4Address() { 13 | try { 14 | String ipv4; 15 | ArrayList nilist = Collections.list(NetworkInterface.getNetworkInterfaces()); 16 | for (NetworkInterface ni : nilist) { 17 | ArrayList ialist = Collections.list(ni.getInetAddresses()); 18 | for (InetAddress address : ialist) { 19 | if (!address.isLoopbackAddress() && !address.isLinkLocalAddress()) { 20 | ipv4 = address.getHostAddress(); 21 | return ipv4; 22 | } 23 | } 24 | } 25 | } catch (SocketException ex) { 26 | Log.e("localip", ex.toString()); 27 | } 28 | return null; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/exceptions/InvalidEncodingException.java: -------------------------------------------------------------------------------- 1 | package org.java_ws.exceptions; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | 5 | /** 6 | * The Character Encoding is not supported. 7 | * 8 | * @since 1.4.0 9 | */ 10 | public class InvalidEncodingException extends RuntimeException { 11 | 12 | /** 13 | * attribute for the encoding exception 14 | */ 15 | private final UnsupportedEncodingException encodingException; 16 | 17 | /** 18 | * constructor for InvalidEncodingException 19 | * 20 | * @param encodingException the cause for this exception 21 | */ 22 | public InvalidEncodingException(UnsupportedEncodingException encodingException) { 23 | if (encodingException == null) 24 | throw new IllegalArgumentException(); 25 | this.encodingException = encodingException; 26 | } 27 | 28 | /** 29 | * Get the exception which includes more information on the unsupported encoding 30 | * @return an UnsupportedEncodingException 31 | */ 32 | public UnsupportedEncodingException getEncodingException() { 33 | return encodingException; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/java/com/td/exoplayerdemo/WebActivity.java: -------------------------------------------------------------------------------- 1 | package com.td.exoplayerdemo; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.webkit.WebView; 6 | 7 | import com.google.connectlib.EmptyClient; 8 | 9 | import org.java_websocket.client.WebSocketClient; 10 | 11 | import java.net.URI; 12 | import java.net.URISyntaxException; 13 | 14 | public class WebActivity extends AppCompatActivity { 15 | private WebView webView; 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.activity_web); 21 | webView = findViewById(R.id.wv); 22 | webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); 23 | webView.getSettings().setJavaScriptEnabled(true); 24 | webView.loadUrl("file:///android_asset/index.html"); 25 | EmptyClient client = null; 26 | try { 27 | client = new EmptyClient(new URI("ws://localhost:8887")); 28 | } catch (URISyntaxException e) { 29 | e.printStackTrace(); 30 | } 31 | client.connect(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/exceptions/InvalidEncodingException.java: -------------------------------------------------------------------------------- 1 | package org.java_websocket.exceptions; 2 | 3 | import java.io.UnsupportedEncodingException; 4 | 5 | /** 6 | * The Character Encoding is not supported. 7 | * 8 | * @since 1.4.0 9 | */ 10 | public class InvalidEncodingException extends RuntimeException { 11 | 12 | /** 13 | * attribute for the encoding exception 14 | */ 15 | private final UnsupportedEncodingException encodingException; 16 | 17 | /** 18 | * constructor for InvalidEncodingException 19 | * 20 | * @param encodingException the cause for this exception 21 | */ 22 | public InvalidEncodingException(UnsupportedEncodingException encodingException) { 23 | if (encodingException == null) 24 | throw new IllegalArgumentException(); 25 | this.encodingException = encodingException; 26 | } 27 | 28 | /** 29 | * Get the exception which includes more information on the unsupported encoding 30 | * @return an UnsupportedEncodingException 31 | */ 32 | public UnsupportedEncodingException getEncodingException() { 33 | return encodingException; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /app/src/main/assets/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ws 7 | 10 | 11 | 12 | 13 |
14 | 15 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /exoplayer/src/main/java/com/google/android/exoplayer2/ext/ffmpeg/FfmpegDecoderException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.google.android.exoplayer2.ext.ffmpeg; 17 | 18 | import com.google.android.exoplayer2.audio.AudioDecoderException; 19 | 20 | /** 21 | * Thrown when an FFmpeg decoder error occurs. 22 | */ 23 | public final class FfmpegDecoderException extends AudioDecoderException { 24 | 25 | /* package */ FfmpegDecoderException(String message) { 26 | super(message); 27 | } 28 | 29 | /* package */ FfmpegDecoderException(String message, Throwable cause) { 30 | super(message, cause); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/src/main/res/layout/item_tvprogram.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 23 | 24 | 33 | -------------------------------------------------------------------------------- /exoplayer/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 28 5 | 6 | defaultConfig { 7 | minSdkVersion 16 8 | targetSdkVersion 28 9 | versionCode 1 10 | versionName "1.0" 11 | // multiDexEnabled true 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | 14 | } 15 | 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | 23 | compileOptions { 24 | sourceCompatibility JavaVersion.VERSION_1_8 25 | targetCompatibility JavaVersion.VERSION_1_8 26 | } 27 | 28 | } 29 | 30 | dependencies { 31 | implementation fileTree(dir: 'libs', include: ['*.jar']) 32 | implementation 'com.google.android.exoplayer:exoplayer:2.9.6' 33 | implementation 'com.github.bumptech.glide:glide:4.9.0' 34 | annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0' 35 | implementation 'com.airbnb.android:lottie:2.7.0' 36 | testImplementation 'junit:junit:4.12' 37 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 38 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 39 | } 40 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/enums/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all enums. 28 | */ 29 | package org.java_ws.enums; -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/util/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates the utility classes. 28 | */ 29 | package org.java_ws.util; -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/enums/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all enums. 28 | */ 29 | package org.java_websocket.enums; -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/util/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates the utility classes. 28 | */ 29 | package org.java_websocket.util; -------------------------------------------------------------------------------- /exoplayer/src/main/res/layout/layout_volumn_toast.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 16 | 17 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/client/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all implementations in relation with the WebSocketClient. 28 | */ 29 | package org.java_ws.client; -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/drafts/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all implementations in relation with the WebSocket drafts. 28 | */ 29 | package org.java_ws.drafts; -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/server/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all implementations in relation with the WebSocketServer. 28 | */ 29 | package org.java_ws.server; -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/client/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all implementations in relation with the WebSocketClient. 28 | */ 29 | package org.java_websocket.client; -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/drafts/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all implementations in relation with the WebSocket drafts. 28 | */ 29 | package org.java_websocket.drafts; -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/server/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all implementations in relation with the WebSocketServer. 28 | */ 29 | package org.java_websocket.server; -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/exceptions/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all implementations in relation with the exceptions thrown in this lib. 28 | */ 29 | package org.java_ws.exceptions; -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/framing/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all interfaces and implementations in relation with the WebSocket frames. 28 | */ 29 | package org.java_ws.framing; -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/framing/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all interfaces and implementations in relation with the WebSocket frames. 28 | */ 29 | package org.java_websocket.framing; -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/exceptions/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all implementations in relation with the exceptions thrown in this lib. 28 | */ 29 | package org.java_websocket.exceptions; -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/handshake/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all interfaces and implementations in relation with the WebSocket handshake. 28 | */ 29 | package org.java_ws.handshake; 30 | 31 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/extensions/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all interfaces and implementations in relation with the WebSocket Sec-WebSocket-Extensions. 28 | */ 29 | package org.java_ws.extensions; -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/protocols/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all interfaces and implementations in relation with the WebSocket Sec-WebSocket-Protocol. 28 | */ 29 | package org.java_ws.protocols; -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/handshake/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all interfaces and implementations in relation with the WebSocket handshake. 28 | */ 29 | package org.java_websocket.handshake; 30 | 31 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/protocols/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all interfaces and implementations in relation with the WebSocket Sec-WebSocket-Protocol. 28 | */ 29 | package org.java_websocket.protocols; -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/extensions/package-info.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | /** 27 | * This package encapsulates all interfaces and implementations in relation with the WebSocket Sec-WebSocket-Extensions. 28 | */ 29 | package org.java_websocket.extensions; -------------------------------------------------------------------------------- /exoplayer/src/main/res/drawable/progressbar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 12 | 13 | 22 | 23 | 32 | 33 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /exoplayer/src/main/java/com/td/exoplayer/FFMPEGRenderFactory.java: -------------------------------------------------------------------------------- 1 | package com.td.exoplayer; 2 | 3 | 4 | import android.content.Context; 5 | import android.os.Handler; 6 | import android.support.annotation.Nullable; 7 | 8 | import com.google.android.exoplayer2.DefaultRenderersFactory; 9 | import com.google.android.exoplayer2.Renderer; 10 | import com.google.android.exoplayer2.audio.AudioProcessor; 11 | import com.google.android.exoplayer2.audio.AudioRendererEventListener; 12 | import com.google.android.exoplayer2.drm.DrmSessionManager; 13 | import com.google.android.exoplayer2.drm.FrameworkMediaCrypto; 14 | import com.google.android.exoplayer2.ext.ffmpeg.FfmpegAudioRenderer; 15 | import com.google.android.exoplayer2.mediacodec.MediaCodecSelector; 16 | 17 | import java.util.ArrayList; 18 | 19 | public class FFMPEGRenderFactory extends DefaultRenderersFactory { 20 | 21 | public FFMPEGRenderFactory(Context context) { 22 | super(context); 23 | } 24 | 25 | @Override 26 | protected void buildAudioRenderers(Context context, int extensionRendererMode, MediaCodecSelector mediaCodecSelector, @Nullable DrmSessionManager drmSessionManager, boolean playClearSamplesWithoutKeys, AudioProcessor[] audioProcessors, Handler eventHandler, AudioRendererEventListener eventListener, ArrayList out) { 27 | super.buildAudioRenderers(context, extensionRendererMode, mediaCodecSelector, drmSessionManager, playClearSamplesWithoutKeys, audioProcessors, eventHandler, eventListener, out); 28 | out.add(new FfmpegAudioRenderer()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2019, 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | defaultConfig { 6 | applicationId "com.td.exoplayerdemo" 7 | minSdkVersion 17 8 | targetSdkVersion 28 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | multiDexEnabled true 13 | } 14 | 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | 22 | compileOptions { 23 | sourceCompatibility JavaVersion.VERSION_1_8 24 | targetCompatibility JavaVersion.VERSION_1_8 25 | } 26 | } 27 | 28 | dependencies { 29 | implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) 30 | implementation 'com.android.support:appcompat-v7:28.0.0' 31 | implementation 'com.android.support:design:28.0.0' 32 | implementation 'com.android.support.constraint:constraint-layout:1.1.3' 33 | implementation 'com.android.support:leanback-v17:28.0.0' 34 | implementation 'com.github.jaychou2012:SmartRecyclerView:1.01' 35 | implementation 'com.google.android.exoplayer:exoplayer:2.9.6' 36 | implementation project(':exoplayer') 37 | implementation project(':connectlib') 38 | testImplementation 'junit:junit:4.12' 39 | androidTestImplementation 'com.android.support.test:runner:1.0.2' 40 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' 41 | } 42 | -------------------------------------------------------------------------------- /connectlib/src/main/java/com/google/connectlib/EmptyClient.java: -------------------------------------------------------------------------------- 1 | package com.google.connectlib; 2 | 3 | import org.java_ws.client.WebSocketClient; 4 | import org.java_ws.drafts.Draft; 5 | import org.java_ws.handshake.ServerHandshake; 6 | 7 | import java.net.URI; 8 | import java.net.URISyntaxException; 9 | import java.nio.ByteBuffer; 10 | 11 | public class EmptyClient extends WebSocketClient { 12 | 13 | public EmptyClient(URI serverUri, Draft draft) { 14 | super(serverUri, draft); 15 | } 16 | 17 | public EmptyClient(URI serverURI) { 18 | super(serverURI); 19 | } 20 | 21 | @Override 22 | public void onOpen(ServerHandshake handshakedata) { 23 | send("Hello, it is me. Mario :)"); 24 | System.out.println("new connection opened"); 25 | } 26 | 27 | @Override 28 | public void onClose(int code, String reason, boolean remote) { 29 | System.out.println("closed with exit code " + code + " additional info: " + reason); 30 | } 31 | 32 | @Override 33 | public void onMessage(String message) { 34 | System.out.println("received message: " + message); 35 | } 36 | 37 | @Override 38 | public void onMessage(ByteBuffer message) { 39 | System.out.println("received ByteBuffer"); 40 | } 41 | 42 | @Override 43 | public void onError(Exception ex) { 44 | System.err.println("an error occurred:" + ex); 45 | } 46 | 47 | public static void main(String[] args) throws URISyntaxException { 48 | WebSocketClient client = new EmptyClient(new URI("ws://localhost:8887")); 49 | client.connect(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/framing/PingFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws.framing; 27 | 28 | import org.java_ws.enums.Opcode; 29 | 30 | /** 31 | * Class to represent a ping frame 32 | */ 33 | public class PingFrame extends ControlFrame { 34 | 35 | /** 36 | * constructor which sets the opcode of this frame to ping 37 | */ 38 | public PingFrame() { 39 | super(Opcode.PING); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/framing/PingFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.framing; 27 | 28 | import org.java_websocket.enums.Opcode; 29 | 30 | /** 31 | * Class to represent a ping frame 32 | */ 33 | public class PingFrame extends ControlFrame { 34 | 35 | /** 36 | * constructor which sets the opcode of this frame to ping 37 | */ 38 | public PingFrame() { 39 | super(Opcode.PING); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/framing/BinaryFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws.framing; 27 | 28 | import org.java_ws.enums.Opcode; 29 | 30 | /** 31 | * Class to represent a binary frame 32 | */ 33 | public class BinaryFrame extends DataFrame { 34 | 35 | /** 36 | * constructor which sets the opcode of this frame to binary 37 | */ 38 | public BinaryFrame() { 39 | super(Opcode.BINARY); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/handshake/ClientHandshake.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws.handshake; 27 | 28 | /** 29 | * The interface for a client handshake 30 | */ 31 | public interface ClientHandshake extends Handshakedata { 32 | 33 | /** 34 | * returns the HTTP Request-URI as defined by http://tools.ietf.org/html/rfc2616#section-5.1.2 35 | * @return the HTTP Request-URI 36 | */ 37 | String getResourceDescriptor(); 38 | } 39 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/exceptions/WebsocketNotConnectedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws.exceptions; 27 | 28 | /** 29 | * exception which indicates the websocket is not yet connected (ReadyState.OPEN) 30 | */ 31 | public class WebsocketNotConnectedException extends RuntimeException { 32 | 33 | /** 34 | * Serializable 35 | */ 36 | private static final long serialVersionUID = -785314021592982715L; 37 | } 38 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/framing/ContinuousFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws.framing; 27 | 28 | import org.java_ws.enums.Opcode; 29 | 30 | /** 31 | * Class to represent a continuous frame 32 | */ 33 | public class ContinuousFrame extends DataFrame { 34 | 35 | /** 36 | * constructor which sets the opcode of this frame to continuous 37 | */ 38 | public ContinuousFrame() { 39 | super( Opcode.CONTINUOUS ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | *.aab 5 | 6 | # Files for the ART/Dalvik VM 7 | *.dex 8 | 9 | # Java class files 10 | *.class 11 | 12 | # Generated files 13 | bin/ 14 | gen/ 15 | out/ 16 | release/ 17 | 18 | # Gradle files 19 | .gradle/ 20 | build/ 21 | 22 | # Local configuration file (sdk path, etc) 23 | local.properties 24 | 25 | # Proguard folder generated by Eclipse 26 | proguard/ 27 | 28 | # Log Files 29 | *.log 30 | 31 | # Android Studio Navigation editor temp files 32 | .navigation/ 33 | 34 | # Android Studio captures folder 35 | captures/ 36 | 37 | # IntelliJ 38 | *.iml 39 | .idea/workspace.xml 40 | .idea/tasks.xml 41 | .idea/gradle.xml 42 | .idea/assetWizardSettings.xml 43 | .idea/dictionaries 44 | .idea/libraries 45 | # Android Studio 3 in .gitignore file. 46 | .idea/caches 47 | .idea/modules.xml 48 | # Comment next line if keeping position of elements in Navigation Editor is relevant for you 49 | .idea/navEditor.xml 50 | 51 | # Keystore files 52 | # Uncomment the following lines if you do not want to check your keystore files in. 53 | #*.jks 54 | #*.keystore 55 | 56 | # External native build folder generated in Android Studio 2.2 and later 57 | .externalNativeBuild 58 | 59 | # Google Services (e.g. APIs or Firebase) 60 | # google-services.json 61 | 62 | # Freeline 63 | freeline.py 64 | freeline/ 65 | freeline_project_description.json 66 | 67 | # fastlane 68 | fastlane/report.xml 69 | fastlane/Preview.html 70 | fastlane/screenshots 71 | fastlane/test_output 72 | fastlane/readme.md 73 | 74 | # Version control 75 | vcs.xml 76 | 77 | # lint 78 | lint/intermediates/ 79 | lint/generated/ 80 | lint/outputs/ 81 | lint/tmp/ 82 | # lint/reports/ 83 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/handshake/ClientHandshake.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.handshake; 27 | 28 | /** 29 | * The interface for a client handshake 30 | */ 31 | public interface ClientHandshake extends Handshakedata { 32 | 33 | /** 34 | * returns the HTTP Request-URI as defined by http://tools.ietf.org/html/rfc2616#section-5.1.2 35 | * @return the HTTP Request-URI 36 | */ 37 | String getResourceDescriptor(); 38 | } 39 | -------------------------------------------------------------------------------- /exoplayer/src/main/res/layout/layout_exoplayer_top.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 19 | 20 | 31 | 32 | 44 | 45 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/exceptions/WebsocketNotConnectedException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.exceptions; 27 | 28 | /** 29 | * exception which indicates the websocket is not yet connected (ReadyState.OPEN) 30 | */ 31 | public class WebsocketNotConnectedException extends RuntimeException { 32 | 33 | /** 34 | * Serializable 35 | */ 36 | private static final long serialVersionUID = -785314021592982715L; 37 | } 38 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/framing/BinaryFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.framing; 27 | 28 | import org.java_websocket.enums.Opcode; 29 | 30 | /** 31 | * Class to represent a binary frame 32 | */ 33 | public class BinaryFrame extends DataFrame { 34 | 35 | /** 36 | * constructor which sets the opcode of this frame to binary 37 | */ 38 | public BinaryFrame() { 39 | super(Opcode.BINARY); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/framing/ContinuousFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.framing; 27 | 28 | import org.java_websocket.enums.Opcode; 29 | 30 | /** 31 | * Class to represent a continuous frame 32 | */ 33 | public class ContinuousFrame extends DataFrame { 34 | 35 | /** 36 | * constructor which sets the opcode of this frame to continuous 37 | */ 38 | public ContinuousFrame() { 39 | super( Opcode.CONTINUOUS ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/handshake/ClientHandshakeBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws.handshake; 27 | 28 | /** 29 | * The interface for building a handshake for the client 30 | */ 31 | public interface ClientHandshakeBuilder extends HandshakeBuilder, ClientHandshake { 32 | 33 | /** 34 | * Set a specific resource descriptor 35 | * @param resourceDescriptor the resource descriptior to set 36 | */ 37 | void setResourceDescriptor( String resourceDescriptor ); 38 | } 39 | -------------------------------------------------------------------------------- /exoplayer/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | exoplayer 3 | 4 | 播放失败,请稍候重试 5 | 6 | Unexpected intent action: %1$s 7 | 8 | Cleartext traffic not permitted 9 | 10 | Unrecognized ABR algorithm 11 | 12 | Unrecognized stereo mode 13 | 14 | Protected content not supported on API levels below 18 15 | 16 | This device does not support the required DRM scheme 17 | 18 | An unknown DRM error occurred 19 | 20 | This device does not provide a decoder for %1$s 21 | 22 | This device does not provide a secure decoder for %1$s 23 | 24 | Unable to query device decoders 25 | 26 | Unable to instantiate decoder %1$s 27 | 28 | Media includes video tracks, but none are playable by this device 29 | 30 | Media includes audio tracks, but none are playable by this device 31 | 32 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/handshake/ClientHandshakeBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.handshake; 27 | 28 | /** 29 | * The interface for building a handshake for the client 30 | */ 31 | public interface ClientHandshakeBuilder extends HandshakeBuilder, ClientHandshake { 32 | 33 | /** 34 | * Set a specific resource descriptor 35 | * @param resourceDescriptor the resource descriptior to set 36 | */ 37 | void setResourceDescriptor( String resourceDescriptor ); 38 | } 39 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/handshake/ServerHandshake.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws.handshake; 27 | 28 | /** 29 | * Interface for the server handshake 30 | */ 31 | public interface ServerHandshake extends Handshakedata { 32 | 33 | /** 34 | * Get the http status code 35 | * @return the http status code 36 | */ 37 | short getHttpStatus(); 38 | 39 | /** 40 | * Get the http status message 41 | * @return the http status message 42 | */ 43 | String getHttpStatusMessage(); 44 | } 45 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/handshake/ServerHandshake.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.handshake; 27 | 28 | /** 29 | * Interface for the server handshake 30 | */ 31 | public interface ServerHandshake extends Handshakedata { 32 | 33 | /** 34 | * Get the http status code 35 | * @return the http status code 36 | */ 37 | short getHttpStatus(); 38 | 39 | /** 40 | * Get the http status message 41 | * @return the http status message 42 | */ 43 | String getHttpStatusMessage(); 44 | } 45 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/handshake/HandshakeBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws.handshake; 27 | 28 | /** 29 | * The interface for building a handshake 30 | */ 31 | public interface HandshakeBuilder extends Handshakedata { 32 | 33 | /** 34 | * Setter for the content of the handshake 35 | * @param content the content to set 36 | */ 37 | void setContent( byte[] content ); 38 | 39 | /** 40 | * Adding a specific field with a specific value 41 | * @param name the http field 42 | * @param value the value for this field 43 | */ 44 | void put( String name, String value ); 45 | } 46 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/handshake/ServerHandshakeBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws.handshake; 27 | 28 | /** 29 | * The interface for building a handshake for the server 30 | */ 31 | public interface ServerHandshakeBuilder extends HandshakeBuilder, ServerHandshake { 32 | 33 | /** 34 | * Setter for the http status code 35 | * @param status the http status code 36 | */ 37 | void setHttpStatus( short status ); 38 | 39 | /** 40 | * Setter for the http status message 41 | * @param message the http status message 42 | */ 43 | void setHttpStatusMessage( String message ); 44 | } 45 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/handshake/HandshakeBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.handshake; 27 | 28 | /** 29 | * The interface for building a handshake 30 | */ 31 | public interface HandshakeBuilder extends Handshakedata { 32 | 33 | /** 34 | * Setter for the content of the handshake 35 | * @param content the content to set 36 | */ 37 | void setContent( byte[] content ); 38 | 39 | /** 40 | * Adding a specific field with a specific value 41 | * @param name the http field 42 | * @param value the value for this field 43 | */ 44 | void put( String name, String value ); 45 | } 46 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/handshake/ServerHandshakeBuilder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.handshake; 27 | 28 | /** 29 | * The interface for building a handshake for the server 30 | */ 31 | public interface ServerHandshakeBuilder extends HandshakeBuilder, ServerHandshake { 32 | 33 | /** 34 | * Setter for the http status code 35 | * @param status the http status code 36 | */ 37 | void setHttpStatus( short status ); 38 | 39 | /** 40 | * Setter for the http status message 41 | * @param message the http status message 42 | */ 43 | void setHttpStatusMessage( String message ); 44 | } 45 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/framing/DataFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws.framing; 27 | 28 | import org.java_ws.enums.Opcode; 29 | import org.java_ws.exceptions.InvalidDataException; 30 | 31 | /** 32 | * Abstract class to represent data frames 33 | */ 34 | public abstract class DataFrame extends FramedataImpl1 { 35 | 36 | /** 37 | * Class to represent a data frame 38 | * @param opcode the opcode to use 39 | */ 40 | public DataFrame(Opcode opcode) { 41 | super(opcode); 42 | } 43 | 44 | @Override 45 | public void isValid() throws InvalidDataException 46 | { 47 | //Nothing specific to check 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/framing/DataFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.framing; 27 | 28 | import org.java_websocket.enums.Opcode; 29 | import org.java_websocket.exceptions.InvalidDataException; 30 | 31 | /** 32 | * Abstract class to represent data frames 33 | */ 34 | public abstract class DataFrame extends FramedataImpl1 { 35 | 36 | /** 37 | * Class to represent a data frame 38 | * @param opcode the opcode to use 39 | */ 40 | public DataFrame(Opcode opcode) { 41 | super(opcode); 42 | } 43 | 44 | @Override 45 | public void isValid() throws InvalidDataException 46 | { 47 | //Nothing specific to check 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /exoplayer/src/main/res/layout/layout_touchcontrollview.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 24 | 25 | 36 | 37 | 47 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | ws 7 | 10 | 55 | 56 | 57 | 58 |
59 | 60 |
61 |
62 | 63 |
64 |
65 |
66 |
67 | 68 | 69 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/framing/PongFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws.framing; 27 | 28 | import org.java_ws.enums.Opcode; 29 | 30 | /** 31 | * Class to represent a pong frame 32 | */ 33 | public class PongFrame extends ControlFrame { 34 | 35 | /** 36 | * constructor which sets the opcode of this frame to pong 37 | */ 38 | public PongFrame() { 39 | super(Opcode.PONG); 40 | } 41 | 42 | /** 43 | * constructor which sets the opcode of this frame to ping copying over the payload of the ping 44 | * 45 | * @param pingFrame the PingFrame which payload is to copy 46 | */ 47 | public PongFrame(PingFrame pingFrame) { 48 | super(Opcode.PONG); 49 | setPayload(pingFrame.getPayloadData()); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/handshake/HandshakeImpl1Client.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws.handshake; 27 | 28 | /** 29 | * Implementation for a client handshake 30 | */ 31 | public class HandshakeImpl1Client extends HandshakedataImpl1 implements ClientHandshakeBuilder { 32 | 33 | /** 34 | * Attribute for the resource descriptor 35 | */ 36 | private String resourceDescriptor = "*"; 37 | 38 | @Override 39 | public void setResourceDescriptor( String resourceDescriptor ) { 40 | if(resourceDescriptor==null) 41 | throw new IllegalArgumentException( "http resource descriptor must not be null" ); 42 | this.resourceDescriptor = resourceDescriptor; 43 | } 44 | 45 | @Override 46 | public String getResourceDescriptor() { 47 | return resourceDescriptor; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/handshake/HandshakeImpl1Client.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.handshake; 27 | 28 | /** 29 | * Implementation for a client handshake 30 | */ 31 | public class HandshakeImpl1Client extends HandshakedataImpl1 implements ClientHandshakeBuilder { 32 | 33 | /** 34 | * Attribute for the resource descriptor 35 | */ 36 | private String resourceDescriptor = "*"; 37 | 38 | @Override 39 | public void setResourceDescriptor( String resourceDescriptor ) { 40 | if(resourceDescriptor==null) 41 | throw new IllegalArgumentException( "http resource descriptor must not be null" ); 42 | this.resourceDescriptor = resourceDescriptor; 43 | } 44 | 45 | @Override 46 | public String getResourceDescriptor() { 47 | return resourceDescriptor; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/framing/PongFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.framing; 27 | 28 | import org.java_websocket.enums.Opcode; 29 | 30 | /** 31 | * Class to represent a pong frame 32 | */ 33 | public class PongFrame extends ControlFrame { 34 | 35 | /** 36 | * constructor which sets the opcode of this frame to pong 37 | */ 38 | public PongFrame() { 39 | super(Opcode.PONG); 40 | } 41 | 42 | /** 43 | * constructor which sets the opcode of this frame to ping copying over the payload of the ping 44 | * 45 | * @param pingFrame the PingFrame which payload is to copy 46 | */ 47 | public PongFrame(PingFrame pingFrame) { 48 | super(Opcode.PONG); 49 | setPayload(pingFrame.getPayloadData()); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/WebSocketFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws; 27 | 28 | import java.util.List; 29 | 30 | import org.java_ws.drafts.Draft; 31 | 32 | public interface WebSocketFactory { 33 | /** 34 | * Create a new Websocket with the provided listener, drafts and socket 35 | * @param a The Listener for the WebsocketImpl 36 | * @param d The draft which should be used 37 | * @return A WebsocketImpl 38 | */ 39 | WebSocket createWebSocket( WebSocketAdapter a, Draft d); 40 | 41 | /** 42 | * Create a new Websocket with the provided listener, drafts and socket 43 | * @param a The Listener for the WebsocketImpl 44 | * @param drafts The drafts which should be used 45 | * @return A WebsocketImpl 46 | */ 47 | WebSocket createWebSocket( WebSocketAdapter a, List drafts); 48 | 49 | } 50 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/WebSocketFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket; 27 | 28 | import java.util.List; 29 | 30 | import org.java_websocket.drafts.Draft; 31 | 32 | public interface WebSocketFactory { 33 | /** 34 | * Create a new Websocket with the provided listener, drafts and socket 35 | * @param a The Listener for the WebsocketImpl 36 | * @param d The draft which should be used 37 | * @return A WebsocketImpl 38 | */ 39 | WebSocket createWebSocket( WebSocketAdapter a, Draft d); 40 | 41 | /** 42 | * Create a new Websocket with the provided listener, drafts and socket 43 | * @param a The Listener for the WebsocketImpl 44 | * @param drafts The drafts which should be used 45 | * @return A WebsocketImpl 46 | */ 47 | WebSocket createWebSocket( WebSocketAdapter a, List drafts); 48 | 49 | } 50 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/framing/TextFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws.framing; 27 | 28 | import org.java_ws.enums.Opcode; 29 | import org.java_ws.exceptions.InvalidDataException; 30 | import org.java_ws.util.Charsetfunctions; 31 | 32 | /** 33 | * Class to represent a text frames 34 | */ 35 | public class TextFrame extends DataFrame { 36 | 37 | /** 38 | * constructor which sets the opcode of this frame to text 39 | */ 40 | public TextFrame() { 41 | super(Opcode.TEXT); 42 | } 43 | 44 | @Override 45 | public void isValid() throws InvalidDataException { 46 | super.isValid(); 47 | if (!Charsetfunctions.isValidUTF8( getPayloadData() )) { 48 | throw new InvalidDataException(CloseFrame.NO_UTF8, "Received text is no valid utf8 string!"); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/framing/TextFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.framing; 27 | 28 | import org.java_websocket.enums.Opcode; 29 | import org.java_websocket.exceptions.InvalidDataException; 30 | import org.java_websocket.util.Charsetfunctions; 31 | 32 | /** 33 | * Class to represent a text frames 34 | */ 35 | public class TextFrame extends DataFrame { 36 | 37 | /** 38 | * constructor which sets the opcode of this frame to text 39 | */ 40 | public TextFrame() { 41 | super(Opcode.TEXT); 42 | } 43 | 44 | @Override 45 | public void isValid() throws InvalidDataException { 46 | super.isValid(); 47 | if (!Charsetfunctions.isValidUTF8( getPayloadData() )) { 48 | throw new InvalidDataException(CloseFrame.NO_UTF8, "Received text is no valid utf8 string!"); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/exceptions/IncompleteException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws.exceptions; 27 | 28 | /** 29 | * Exception which indicates that the frame is not yet complete 30 | */ 31 | public class IncompleteException extends Exception { 32 | 33 | /** 34 | * It's Serializable. 35 | */ 36 | private static final long serialVersionUID = 7330519489840500997L; 37 | 38 | /** 39 | * The preferred size 40 | */ 41 | private final int preferredSize; 42 | 43 | /** 44 | * Constructor for the preferred size of a frame 45 | * @param preferredSize the preferred size of a frame 46 | */ 47 | public IncompleteException( int preferredSize ) { 48 | this.preferredSize = preferredSize; 49 | } 50 | 51 | /** 52 | * Getter for the preferredSize 53 | * @return the value of the preferred size 54 | */ 55 | public int getPreferredSize() { 56 | return preferredSize; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/exceptions/IncompleteException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.exceptions; 27 | 28 | /** 29 | * Exception which indicates that the frame is not yet complete 30 | */ 31 | public class IncompleteException extends Exception { 32 | 33 | /** 34 | * It's Serializable. 35 | */ 36 | private static final long serialVersionUID = 7330519489840500997L; 37 | 38 | /** 39 | * The preferred size 40 | */ 41 | private final int preferredSize; 42 | 43 | /** 44 | * Constructor for the preferred size of a frame 45 | * @param preferredSize the preferred size of a frame 46 | */ 47 | public IncompleteException( int preferredSize ) { 48 | this.preferredSize = preferredSize; 49 | } 50 | 51 | /** 52 | * Getter for the preferredSize 53 | * @return the value of the preferred size 54 | */ 55 | public int getPreferredSize() { 56 | return preferredSize; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/handshake/HandshakeImpl1Server.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws.handshake; 27 | 28 | /** 29 | * Implementation for a server handshake 30 | */ 31 | public class HandshakeImpl1Server extends HandshakedataImpl1 implements ServerHandshakeBuilder { 32 | 33 | /** 34 | * Attribute for the http status 35 | */ 36 | private short httpstatus; 37 | 38 | /** 39 | * Attribute for the http status message 40 | */ 41 | private String httpstatusmessage; 42 | 43 | @Override 44 | public String getHttpStatusMessage() { 45 | return httpstatusmessage; 46 | } 47 | 48 | @Override 49 | public short getHttpStatus() { 50 | return httpstatus; 51 | } 52 | 53 | @Override 54 | public void setHttpStatusMessage( String message ) { 55 | this.httpstatusmessage = message; 56 | } 57 | 58 | @Override 59 | public void setHttpStatus( short status ) { 60 | httpstatus = status; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/handshake/HandshakeImpl1Server.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.handshake; 27 | 28 | /** 29 | * Implementation for a server handshake 30 | */ 31 | public class HandshakeImpl1Server extends HandshakedataImpl1 implements ServerHandshakeBuilder { 32 | 33 | /** 34 | * Attribute for the http status 35 | */ 36 | private short httpstatus; 37 | 38 | /** 39 | * Attribute for the http status message 40 | */ 41 | private String httpstatusmessage; 42 | 43 | @Override 44 | public String getHttpStatusMessage() { 45 | return httpstatusmessage; 46 | } 47 | 48 | @Override 49 | public short getHttpStatus() { 50 | return httpstatus; 51 | } 52 | 53 | @Override 54 | public void setHttpStatusMessage( String message ) { 55 | this.httpstatusmessage = message; 56 | } 57 | 58 | @Override 59 | public void setHttpStatus( short status ) { 60 | httpstatus = status; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/handshake/Handshakedata.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws.handshake; 27 | 28 | import java.util.Iterator; 29 | 30 | /** 31 | * The interface for the data of a handshake 32 | */ 33 | public interface Handshakedata { 34 | 35 | /** 36 | * Iterator for the http fields 37 | * @return the http fields 38 | */ 39 | Iterator iterateHttpFields(); 40 | 41 | /** 42 | * Gets the value of the field 43 | * @param name The name of the field 44 | * @return the value of the field or an empty String if not in the handshake 45 | */ 46 | String getFieldValue( String name ); 47 | 48 | /** 49 | * Checks if this handshake contains a specific field 50 | * @param name The name of the field 51 | * @return true, if it contains the field 52 | */ 53 | boolean hasFieldValue( String name ); 54 | 55 | /** 56 | * Get the content of the handshake 57 | * @return the content as byte-array 58 | */ 59 | byte[] getContent(); 60 | } 61 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/handshake/Handshakedata.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.handshake; 27 | 28 | import java.util.Iterator; 29 | 30 | /** 31 | * The interface for the data of a handshake 32 | */ 33 | public interface Handshakedata { 34 | 35 | /** 36 | * Iterator for the http fields 37 | * @return the http fields 38 | */ 39 | Iterator iterateHttpFields(); 40 | 41 | /** 42 | * Gets the value of the field 43 | * @param name The name of the field 44 | * @return the value of the field or an empty String if not in the handshake 45 | */ 46 | String getFieldValue( String name ); 47 | 48 | /** 49 | * Checks if this handshake contains a specific field 50 | * @param name The name of the field 51 | * @return true, if it contains the field 52 | */ 53 | boolean hasFieldValue( String name ); 54 | 55 | /** 56 | * Get the content of the handshake 57 | * @return the content as byte-array 58 | */ 59 | byte[] getContent(); 60 | } 61 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/server/DefaultWebSocketServerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws.server; 27 | 28 | import java.nio.channels.SelectionKey; 29 | import java.nio.channels.SocketChannel; 30 | import java.util.List; 31 | 32 | import org.java_ws.WebSocketAdapter; 33 | import org.java_ws.WebSocketImpl; 34 | import org.java_ws.drafts.Draft; 35 | import org.java_ws.WebSocketServerFactory; 36 | 37 | public class DefaultWebSocketServerFactory implements WebSocketServerFactory { 38 | @Override 39 | public WebSocketImpl createWebSocket( WebSocketAdapter a, Draft d) { 40 | return new WebSocketImpl( a, d ); 41 | } 42 | @Override 43 | public WebSocketImpl createWebSocket( WebSocketAdapter a, List d) { 44 | return new WebSocketImpl( a, d ); 45 | } 46 | @Override 47 | public SocketChannel wrapChannel( SocketChannel channel, SelectionKey key ) { 48 | return channel; 49 | } 50 | @Override 51 | public void close() { 52 | //Nothing to do for a normal ws factory 53 | } 54 | } -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/server/DefaultWebSocketServerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.server; 27 | 28 | import java.nio.channels.SelectionKey; 29 | import java.nio.channels.SocketChannel; 30 | import java.util.List; 31 | 32 | import org.java_websocket.WebSocketAdapter; 33 | import org.java_websocket.WebSocketImpl; 34 | import org.java_websocket.drafts.Draft; 35 | import org.java_websocket.WebSocketServerFactory; 36 | 37 | public class DefaultWebSocketServerFactory implements WebSocketServerFactory { 38 | @Override 39 | public WebSocketImpl createWebSocket( WebSocketAdapter a, Draft d) { 40 | return new WebSocketImpl( a, d ); 41 | } 42 | @Override 43 | public WebSocketImpl createWebSocket( WebSocketAdapter a, List d) { 44 | return new WebSocketImpl( a, d ); 45 | } 46 | @Override 47 | public SocketChannel wrapChannel( SocketChannel channel, SelectionKey key ) { 48 | return channel; 49 | } 50 | @Override 51 | public void close() { 52 | //Nothing to do for a normal ws factory 53 | } 54 | } -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/framing/ControlFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws.framing; 27 | 28 | import org.java_ws.enums.Opcode; 29 | import org.java_ws.exceptions.InvalidDataException; 30 | import org.java_ws.exceptions.InvalidFrameException; 31 | 32 | /** 33 | * Abstract class to represent control frames 34 | */ 35 | public abstract class ControlFrame extends FramedataImpl1 { 36 | 37 | /** 38 | * Class to represent a control frame 39 | * @param opcode the opcode to use 40 | */ 41 | public ControlFrame( Opcode opcode ) { 42 | super( opcode ); 43 | } 44 | 45 | @Override 46 | public void isValid() throws InvalidDataException { 47 | if( !isFin() ) { 48 | throw new InvalidFrameException( "Control frame cant have fin==false set" ); 49 | } 50 | if( isRSV1() ) { 51 | throw new InvalidFrameException( "Control frame cant have rsv1==true set" ); 52 | } 53 | if( isRSV2() ) { 54 | throw new InvalidFrameException( "Control frame cant have rsv2==true set" ); 55 | } 56 | if( isRSV3() ) { 57 | throw new InvalidFrameException( "Control frame cant have rsv3==true set" ); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/exceptions/NotSendableException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws.exceptions; 27 | 28 | /** 29 | * exception which indicates the frame payload is not sendable 30 | */ 31 | public class NotSendableException extends RuntimeException { 32 | 33 | /** 34 | * Serializable 35 | */ 36 | private static final long serialVersionUID = -6468967874576651628L; 37 | 38 | /** 39 | * constructor for a NotSendableException 40 | * 41 | * @param s the detail message. 42 | */ 43 | public NotSendableException(String s) { 44 | super(s); 45 | } 46 | 47 | /** 48 | * constructor for a NotSendableException 49 | * 50 | * @param t the throwable causing this exception. 51 | */ 52 | public NotSendableException(Throwable t) { 53 | super(t); 54 | } 55 | 56 | /** 57 | * constructor for a NotSendableException 58 | * 59 | * @param s the detail message. 60 | * @param t the throwable causing this exception. 61 | */ 62 | public NotSendableException(String s, Throwable t) { 63 | super(s, t); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/exceptions/NotSendableException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.exceptions; 27 | 28 | /** 29 | * exception which indicates the frame payload is not sendable 30 | */ 31 | public class NotSendableException extends RuntimeException { 32 | 33 | /** 34 | * Serializable 35 | */ 36 | private static final long serialVersionUID = -6468967874576651628L; 37 | 38 | /** 39 | * constructor for a NotSendableException 40 | * 41 | * @param s the detail message. 42 | */ 43 | public NotSendableException(String s) { 44 | super(s); 45 | } 46 | 47 | /** 48 | * constructor for a NotSendableException 49 | * 50 | * @param t the throwable causing this exception. 51 | */ 52 | public NotSendableException(Throwable t) { 53 | super(t); 54 | } 55 | 56 | /** 57 | * constructor for a NotSendableException 58 | * 59 | * @param s the detail message. 60 | * @param t the throwable causing this exception. 61 | */ 62 | public NotSendableException(String s, Throwable t) { 63 | super(s, t); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/framing/ControlFrame.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.framing; 27 | 28 | import org.java_websocket.enums.Opcode; 29 | import org.java_websocket.exceptions.InvalidDataException; 30 | import org.java_websocket.exceptions.InvalidFrameException; 31 | 32 | /** 33 | * Abstract class to represent control frames 34 | */ 35 | public abstract class ControlFrame extends FramedataImpl1 { 36 | 37 | /** 38 | * Class to represent a control frame 39 | * @param opcode the opcode to use 40 | */ 41 | public ControlFrame( Opcode opcode ) { 42 | super( opcode ); 43 | } 44 | 45 | @Override 46 | public void isValid() throws InvalidDataException { 47 | if( !isFin() ) { 48 | throw new InvalidFrameException( "Control frame cant have fin==false set" ); 49 | } 50 | if( isRSV1() ) { 51 | throw new InvalidFrameException( "Control frame cant have rsv1==true set" ); 52 | } 53 | if( isRSV2() ) { 54 | throw new InvalidFrameException( "Control frame cant have rsv2==true set" ); 55 | } 56 | if( isRSV3() ) { 57 | throw new InvalidFrameException( "Control frame cant have rsv3==true set" ); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/extensions/CompressionExtension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws.extensions; 27 | 28 | import org.java_ws.exceptions.InvalidDataException; 29 | import org.java_ws.exceptions.InvalidFrameException; 30 | import org.java_ws.framing.ControlFrame; 31 | import org.java_ws.framing.DataFrame; 32 | import org.java_ws.framing.Framedata; 33 | 34 | /** 35 | * Implementation for a compression extension specified by https://tools.ietf.org/html/rfc7692 36 | * @since 1.3.5 37 | */ 38 | public abstract class CompressionExtension extends DefaultExtension { 39 | 40 | @Override 41 | public void isFrameValid( Framedata inputFrame ) throws InvalidDataException { 42 | if(( inputFrame instanceof DataFrame ) && ( inputFrame.isRSV2() || inputFrame.isRSV3() )) { 43 | throw new InvalidFrameException( "bad rsv RSV1: " + inputFrame.isRSV1() + " RSV2: " + inputFrame.isRSV2() + " RSV3: " + inputFrame.isRSV3() ); 44 | } 45 | if(( inputFrame instanceof ControlFrame ) && ( inputFrame.isRSV1() || inputFrame.isRSV2() || inputFrame.isRSV3() )) { 46 | throw new InvalidFrameException( "bad rsv RSV1: " + inputFrame.isRSV1() + " RSV2: " + inputFrame.isRSV2() + " RSV3: " + inputFrame.isRSV3() ); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/extensions/CompressionExtension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.extensions; 27 | 28 | import org.java_websocket.exceptions.InvalidDataException; 29 | import org.java_websocket.exceptions.InvalidFrameException; 30 | import org.java_websocket.framing.ControlFrame; 31 | import org.java_websocket.framing.DataFrame; 32 | import org.java_websocket.framing.Framedata; 33 | 34 | /** 35 | * Implementation for a compression extension specified by https://tools.ietf.org/html/rfc7692 36 | * @since 1.3.5 37 | */ 38 | public abstract class CompressionExtension extends DefaultExtension { 39 | 40 | @Override 41 | public void isFrameValid( Framedata inputFrame ) throws InvalidDataException { 42 | if(( inputFrame instanceof DataFrame ) && ( inputFrame.isRSV2() || inputFrame.isRSV3() )) { 43 | throw new InvalidFrameException( "bad rsv RSV1: " + inputFrame.isRSV1() + " RSV2: " + inputFrame.isRSV2() + " RSV3: " + inputFrame.isRSV3() ); 44 | } 45 | if(( inputFrame instanceof ControlFrame ) && ( inputFrame.isRSV1() || inputFrame.isRSV2() || inputFrame.isRSV3() )) { 46 | throw new InvalidFrameException( "bad rsv RSV1: " + inputFrame.isRSV1() + " RSV2: " + inputFrame.isRSV2() + " RSV3: " + inputFrame.isRSV3() ); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /exoplayer/src/main/assets/simple.json: -------------------------------------------------------------------------------- 1 | {"v":"4.11.1","fr":60,"ip":0,"op":68,"w":1920,"h":1080,"nm":"Comp 9","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"n":["0p667_1_0p333_0"],"t":0,"s":[0],"e":[360]},{"t":60}],"ix":10},"p":{"a":0,"k":[926,542,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[94.718,102.5,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[590.451,561.677],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"tm","s":{"a":0,"k":99.5,"ix":1},"e":{"a":0,"k":100,"ix":2},"o":{"a":0,"k":1,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false},{"ty":"st","c":{"a":0,"k":[0.066178865731,0.826732218266,0.973008573055,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":75,"ix":5},"lc":2,"lj":2,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[35.211,-11.951],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 2","np":4,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":68,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"Shape Layer 1","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"n":["0p667_1_0p333_0"],"t":0,"s":[0],"e":[-359]},{"t":60}],"ix":10},"p":{"a":0,"k":[962,540,0],"ix":2},"a":{"a":0,"k":[0,0,0],"ix":1},"s":{"a":0,"k":[100,100,100],"ix":6}},"ao":0,"shapes":[{"ty":"gr","it":[{"ty":"rc","d":1,"s":{"a":0,"k":[116.344,347.531],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"r":{"a":0,"k":62,"ix":4},"nm":"Rectangle Path 1","mn":"ADBE Vector Shape - Rect","hd":false},{"ty":"gf","o":{"a":0,"k":100,"ix":10},"r":1,"g":{"p":3,"k":{"a":0,"k":[0.01,0.782,0.294,0.982,0.505,0.502,0.55,0.944,1,0.223,0.806,0.905],"ix":9}},"s":{"a":0,"k":[4.148,-124.836],"ix":5},"e":{"a":0,"k":[7.484,100.289],"ix":6},"t":1,"nm":"Gradient Fill 1","mn":"ADBE Vector Graphic - G-Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[-5.984,-11.859],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Rectangle 1","np":3,"cix":2,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":68,"st":0,"bm":0}]} -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/exceptions/IncompleteHandshakeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws.exceptions; 27 | 28 | /** 29 | * exception which indicates that a incomplete handshake was recieved 30 | */ 31 | public class IncompleteHandshakeException extends RuntimeException { 32 | 33 | /** 34 | * Serializable 35 | */ 36 | private static final long serialVersionUID = 7906596804233893092L; 37 | 38 | /** 39 | * attribut which size of handshake would have been prefered 40 | */ 41 | private final int preferredSize; 42 | 43 | /** 44 | * constructor for a IncompleteHandshakeException 45 | *

46 | * @param preferredSize the prefered size 47 | */ 48 | public IncompleteHandshakeException(int preferredSize) { 49 | this.preferredSize = preferredSize; 50 | } 51 | 52 | /** 53 | * constructor for a IncompleteHandshakeException 54 | *

55 | * preferredSize will be 0 56 | */ 57 | public IncompleteHandshakeException() { 58 | this.preferredSize = 0; 59 | } 60 | 61 | /** 62 | * Getter preferredSize 63 | * 64 | * @return the preferredSize 65 | */ 66 | public int getPreferredSize() { 67 | return preferredSize; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/exceptions/IncompleteHandshakeException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.exceptions; 27 | 28 | /** 29 | * exception which indicates that a incomplete handshake was recieved 30 | */ 31 | public class IncompleteHandshakeException extends RuntimeException { 32 | 33 | /** 34 | * Serializable 35 | */ 36 | private static final long serialVersionUID = 7906596804233893092L; 37 | 38 | /** 39 | * attribut which size of handshake would have been prefered 40 | */ 41 | private final int preferredSize; 42 | 43 | /** 44 | * constructor for a IncompleteHandshakeException 45 | *

46 | * @param preferredSize the prefered size 47 | */ 48 | public IncompleteHandshakeException(int preferredSize) { 49 | this.preferredSize = preferredSize; 50 | } 51 | 52 | /** 53 | * constructor for a IncompleteHandshakeException 54 | *

55 | * preferredSize will be 0 56 | */ 57 | public IncompleteHandshakeException() { 58 | this.preferredSize = 0; 59 | } 60 | 61 | /** 62 | * Getter preferredSize 63 | * 64 | * @return the preferredSize 65 | */ 66 | public int getPreferredSize() { 67 | return preferredSize; 68 | } 69 | 70 | } 71 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/util/ByteBufferUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws.util; 27 | 28 | import java.nio.ByteBuffer; 29 | 30 | /** 31 | * Utility class for ByteBuffers 32 | */ 33 | public class ByteBufferUtils { 34 | 35 | /** 36 | * Private constructor for static class 37 | */ 38 | private ByteBufferUtils() { 39 | } 40 | 41 | /** 42 | * Transfer from one ByteBuffer to another ByteBuffer 43 | * 44 | * @param source the ByteBuffer to copy from 45 | * @param dest the ByteBuffer to copy to 46 | * @return the number of transferred bytes 47 | */ 48 | public static int transferByteBuffer( ByteBuffer source, ByteBuffer dest ) { 49 | if( source == null || dest == null ) { 50 | throw new IllegalArgumentException(); 51 | } 52 | int fremain = source.remaining(); 53 | int toremain = dest.remaining(); 54 | if( fremain > toremain ) { 55 | int limit = Math.min( fremain, toremain ); 56 | source.limit( limit ); 57 | dest.put( source ); 58 | return limit; 59 | } else { 60 | dest.put( source ); 61 | return fremain; 62 | } 63 | } 64 | 65 | /** 66 | * Get a ByteBuffer with zero capacity 67 | * 68 | * @return empty ByteBuffer 69 | */ 70 | public static ByteBuffer getEmptyByteBuffer() { 71 | return ByteBuffer.allocate( 0 ); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/util/ByteBufferUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.util; 27 | 28 | import java.nio.ByteBuffer; 29 | 30 | /** 31 | * Utility class for ByteBuffers 32 | */ 33 | public class ByteBufferUtils { 34 | 35 | /** 36 | * Private constructor for static class 37 | */ 38 | private ByteBufferUtils() { 39 | } 40 | 41 | /** 42 | * Transfer from one ByteBuffer to another ByteBuffer 43 | * 44 | * @param source the ByteBuffer to copy from 45 | * @param dest the ByteBuffer to copy to 46 | * @return the number of transferred bytes 47 | */ 48 | public static int transferByteBuffer( ByteBuffer source, ByteBuffer dest ) { 49 | if( source == null || dest == null ) { 50 | throw new IllegalArgumentException(); 51 | } 52 | int fremain = source.remaining(); 53 | int toremain = dest.remaining(); 54 | if( fremain > toremain ) { 55 | int limit = Math.min( fremain, toremain ); 56 | source.limit( limit ); 57 | dest.put( source ); 58 | return limit; 59 | } else { 60 | dest.put( source ); 61 | return fremain; 62 | } 63 | } 64 | 65 | /** 66 | * Get a ByteBuffer with zero capacity 67 | * 68 | * @return empty ByteBuffer 69 | */ 70 | public static ByteBuffer getEmptyByteBuffer() { 71 | return ByteBuffer.allocate( 0 ); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/WebSocketServerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws; 27 | 28 | import org.java_ws.drafts.Draft; 29 | 30 | import java.io.IOException; 31 | import java.nio.channels.ByteChannel; 32 | import java.nio.channels.SelectionKey; 33 | import java.nio.channels.SocketChannel; 34 | import java.util.List; 35 | 36 | /** 37 | * Interface to encapsulate the required methods for a websocket factory 38 | */ 39 | public interface WebSocketServerFactory extends WebSocketFactory { 40 | @Override 41 | WebSocketImpl createWebSocket( WebSocketAdapter a, Draft d); 42 | 43 | @Override 44 | WebSocketImpl createWebSocket( WebSocketAdapter a, List drafts ); 45 | 46 | /** 47 | * Allows to wrap the Socketchannel( key.channel() ) to insert a protocol layer( like ssl or proxy authentication) beyond the ws layer. 48 | * 49 | * @param channel The SocketChannel to wrap 50 | * @param key a SelectionKey of an open SocketChannel. 51 | * @return The channel on which the read and write operations will be performed.
52 | * @throws IOException may be thrown while writing on the channel 53 | */ 54 | ByteChannel wrapChannel(SocketChannel channel, SelectionKey key ) throws IOException; 55 | 56 | /** 57 | * Allows to shutdown the websocket factory for a clean shutdown 58 | */ 59 | void close(); 60 | } 61 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/WebSocketServerFactory.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket; 27 | 28 | import org.java_websocket.drafts.Draft; 29 | 30 | import java.io.IOException; 31 | import java.nio.channels.ByteChannel; 32 | import java.nio.channels.SelectionKey; 33 | import java.nio.channels.SocketChannel; 34 | import java.util.List; 35 | 36 | /** 37 | * Interface to encapsulate the required methods for a websocket factory 38 | */ 39 | public interface WebSocketServerFactory extends WebSocketFactory { 40 | @Override 41 | WebSocketImpl createWebSocket( WebSocketAdapter a, Draft d); 42 | 43 | @Override 44 | WebSocketImpl createWebSocket( WebSocketAdapter a, List drafts ); 45 | 46 | /** 47 | * Allows to wrap the Socketchannel( key.channel() ) to insert a protocol layer( like ssl or proxy authentication) beyond the ws layer. 48 | * 49 | * @param channel The SocketChannel to wrap 50 | * @param key a SelectionKey of an open SocketChannel. 51 | * @return The channel on which the read and write operations will be performed.
52 | * @throws IOException may be thrown while writing on the channel 53 | */ 54 | ByteChannel wrapChannel(SocketChannel channel, SelectionKey key ) throws IOException; 55 | 56 | /** 57 | * Allows to shutdown the websocket factory for a clean shutdown 58 | */ 59 | void close(); 60 | } 61 | -------------------------------------------------------------------------------- /connectlib/src/main/java/com/google/connectlib/ConnectService.java: -------------------------------------------------------------------------------- 1 | package com.google.connectlib; 2 | 3 | import android.app.Service; 4 | import android.content.Intent; 5 | import android.os.Handler; 6 | import android.os.IBinder; 7 | import android.os.Message; 8 | import android.support.annotation.Nullable; 9 | 10 | import java.io.IOException; 11 | import java.net.InetSocketAddress; 12 | 13 | public class ConnectService extends Service implements SimpleServer.MessageListener { 14 | private Thread thread; 15 | private SimpleServer server; 16 | private static MessageListener msgListener; 17 | 18 | @Nullable 19 | @Override 20 | public IBinder onBind(Intent intent) { 21 | return null; 22 | } 23 | 24 | @Override 25 | public void onCreate() { 26 | super.onCreate(); 27 | if (thread != null) { 28 | thread = null; 29 | } 30 | thread = new Thread() { 31 | @Override 32 | public void run() { 33 | super.run(); 34 | server = new SimpleServer(getBaseContext(), new InetSocketAddress(Constants.HOST, Constants.PORT)); 35 | server.setMessageListener(ConnectService.this); 36 | server.run(); 37 | } 38 | }; 39 | thread.start(); 40 | } 41 | 42 | private Handler handler = new Handler() { 43 | @Override 44 | public void handleMessage(Message msg) { 45 | super.handleMessage(msg); 46 | if (msgListener != null) { 47 | msgListener.onMessage(msg.obj.toString()); 48 | } 49 | } 50 | }; 51 | 52 | @Override 53 | public int onStartCommand(Intent intent, int flags, int startId) { 54 | return super.onStartCommand(intent, flags, startId); 55 | } 56 | 57 | @Override 58 | public void onDestroy() { 59 | super.onDestroy(); 60 | if (server != null) { 61 | try { 62 | server.stop(); 63 | } catch (IOException e) { 64 | e.printStackTrace(); 65 | } catch (InterruptedException e) { 66 | e.printStackTrace(); 67 | } 68 | } 69 | } 70 | 71 | @Override 72 | public void onMessage(String text) { 73 | Message message = new Message(); 74 | message.obj = text; 75 | handler.sendMessage(message); 76 | } 77 | 78 | public static void setMessageListener(MessageListener messageListener) { 79 | msgListener = messageListener; 80 | } 81 | 82 | public interface MessageListener { 83 | void onMessage(String message); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /app/src/main/java/com/td/exoplayerdemo/adapter/TVListAdapter.java: -------------------------------------------------------------------------------- 1 | package com.td.exoplayerdemo.adapter; 2 | 3 | import android.content.Context; 4 | import android.graphics.Paint; 5 | import android.graphics.Rect; 6 | import android.view.View; 7 | import android.widget.LinearLayout; 8 | 9 | import com.whatjay.recyclerview.adapter.BaseSmartAdapter; 10 | import com.whatjay.recyclerview.viewholder.SmarViewHolder; 11 | 12 | import java.util.List; 13 | 14 | import com.td.exoplayer.utils.Utils; 15 | import com.td.exoplayerdemo.R; 16 | 17 | /** 18 | * Created by office on 2017/8/17. 19 | */ 20 | 21 | public class TVListAdapter extends BaseSmartAdapter { 22 | private Context context; 23 | private int currentPosition = 0; 24 | private int currentFocusPosition = 0; 25 | private String type; 26 | private Paint paint; 27 | private Rect rect; 28 | private LinearLayout.LayoutParams layoutParams; 29 | private String title = ""; 30 | 31 | public TVListAdapter(Context context, int layoutId, List lists, String type) { 32 | super(context, layoutId, lists); 33 | this.context = context; 34 | this.type = type; 35 | paint = new Paint(); 36 | paint.setTextSize(Utils.sp2px(context, 26)); 37 | paint.setFakeBoldText(true); 38 | rect = new Rect(); 39 | layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); 40 | } 41 | 42 | @Override 43 | public void bindData(SmarViewHolder holder, String string) { 44 | paint.getTextBounds(title, 0, title.length(), rect); 45 | layoutParams.width = Utils.dp2px(context, 50) + Utils.dp2px(context, 38); 46 | holder.getView(R.id.ll_list).setLayoutParams(layoutParams); 47 | holder.setText(R.id.tv_tv_name, string); 48 | if (currentPosition == currentFocusPosition && holder.getAdapterPosition() == currentPosition) { 49 | holder.getView(R.id.ll_list).requestFocus(); 50 | } 51 | if (holder.getAdapterPosition() == currentPosition) { 52 | holder.setVisible(R.id.v_select); 53 | } else { 54 | holder.getView(R.id.v_select).setVisibility(View.INVISIBLE); 55 | } 56 | if (currentPosition != currentFocusPosition && holder.getAdapterPosition() == currentFocusPosition) { 57 | holder.getView(R.id.ll_list).requestFocus(); 58 | } 59 | } 60 | 61 | public void setPosition(int position) { 62 | this.currentPosition = position; 63 | notifyDataSetChanged(); 64 | } 65 | 66 | public void setCurrentFocusPosition(int position) { 67 | this.currentFocusPosition = position; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 35 | 38 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 50 | 51 | 54 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/handshake/HandshakedataImpl1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws.handshake; 27 | 28 | import java.util.Collections; 29 | import java.util.Iterator; 30 | import java.util.TreeMap; 31 | 32 | /** 33 | * Implementation of a handshake builder 34 | */ 35 | public class HandshakedataImpl1 implements HandshakeBuilder { 36 | 37 | /** 38 | * Attribute for the content of the handshake 39 | */ 40 | private byte[] content; 41 | 42 | /** 43 | * Attribute for the http fields and values 44 | */ 45 | private TreeMap map; 46 | 47 | /** 48 | * Constructor for handshake implementation 49 | */ 50 | public HandshakedataImpl1() { 51 | map = new TreeMap( String.CASE_INSENSITIVE_ORDER ); 52 | } 53 | 54 | @Override 55 | public Iterator iterateHttpFields() { 56 | return Collections.unmodifiableSet( map.keySet() ).iterator();// Safety first 57 | } 58 | 59 | @Override 60 | public String getFieldValue( String name ) { 61 | String s = map.get( name ); 62 | if ( s == null ) { 63 | return ""; 64 | } 65 | return s; 66 | } 67 | 68 | @Override 69 | public byte[] getContent() { 70 | return content; 71 | } 72 | 73 | @Override 74 | public void setContent( byte[] content ) { 75 | this.content = content; 76 | } 77 | 78 | @Override 79 | public void put( String name, String value ) { 80 | map.put( name, value ); 81 | } 82 | 83 | @Override 84 | public boolean hasFieldValue( String name ) { 85 | return map.containsKey( name ); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_websocket/handshake/HandshakedataImpl1.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_websocket.handshake; 27 | 28 | import java.util.Collections; 29 | import java.util.Iterator; 30 | import java.util.TreeMap; 31 | 32 | /** 33 | * Implementation of a handshake builder 34 | */ 35 | public class HandshakedataImpl1 implements HandshakeBuilder { 36 | 37 | /** 38 | * Attribute for the content of the handshake 39 | */ 40 | private byte[] content; 41 | 42 | /** 43 | * Attribute for the http fields and values 44 | */ 45 | private TreeMap map; 46 | 47 | /** 48 | * Constructor for handshake implementation 49 | */ 50 | public HandshakedataImpl1() { 51 | map = new TreeMap( String.CASE_INSENSITIVE_ORDER ); 52 | } 53 | 54 | @Override 55 | public Iterator iterateHttpFields() { 56 | return Collections.unmodifiableSet( map.keySet() ).iterator();// Safety first 57 | } 58 | 59 | @Override 60 | public String getFieldValue( String name ) { 61 | String s = map.get( name ); 62 | if ( s == null ) { 63 | return ""; 64 | } 65 | return s; 66 | } 67 | 68 | @Override 69 | public byte[] getContent() { 70 | return content; 71 | } 72 | 73 | @Override 74 | public void setContent( byte[] content ) { 75 | this.content = content; 76 | } 77 | 78 | @Override 79 | public void put( String name, String value ) { 80 | map.put( name, value ); 81 | } 82 | 83 | @Override 84 | public boolean hasFieldValue( String name ) { 85 | return map.containsKey( name ); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /connectlib/src/main/java/org/java_ws/WrappedByteChannel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2019 Nathan Rajlich 3 | * 4 | * Permission is hereby granted, free of charge, to any person 5 | * obtaining a copy of this software and associated documentation 6 | * files (the "Software"), to deal in the Software without 7 | * restriction, including without limitation the rights to use, 8 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | * copies of the Software, and to permit persons to whom the 10 | * Software is furnished to do so, subject to the following 11 | * conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | * OTHER DEALINGS IN THE SOFTWARE. 24 | */ 25 | 26 | package org.java_ws; 27 | 28 | import java.io.IOException; 29 | import java.nio.ByteBuffer; 30 | import java.nio.channels.ByteChannel; 31 | 32 | public interface WrappedByteChannel extends ByteChannel { 33 | /** 34 | * returns whether writeMore should be called write additional data. 35 | 36 | * @return is a additional write needed 37 | */ 38 | boolean isNeedWrite(); 39 | 40 | /** 41 | * Gets called when {@link #isNeedWrite()} ()} requires a additional rite 42 | * @throws IOException may be thrown due to an error while writing 43 | */ 44 | void writeMore() throws IOException; 45 | 46 | /** 47 | * returns whether readMore should be called to fetch data which has been decoded but not yet been returned. 48 | * 49 | * @see #read(ByteBuffer) 50 | * @see #readMore(ByteBuffer) 51 | * @return is a additional read needed 52 | **/ 53 | boolean isNeedRead(); 54 | /** 55 | * This function does not read data from the underlying channel at all. It is just a way to fetch data which has already be received or decoded but was but was not yet returned to the user. 56 | * This could be the case when the decoded data did not fit into the buffer the user passed to {@link #read(ByteBuffer)}. 57 | * @param dst the destiny of the read 58 | * @return the amount of remaining data 59 | * @throws IOException when a error occurred during unwrapping 60 | **/ 61 | int readMore( ByteBuffer dst ) throws IOException; 62 | 63 | /** 64 | * This function returns the blocking state of the channel 65 | * @return is the channel blocking 66 | */ 67 | boolean isBlocking(); 68 | } 69 | --------------------------------------------------------------------------------